Change in python/osmo-python-tests[master]: Trap handlers: always log to stdout

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Wed Dec 5 15:43:10 UTC 2018


Max has submitted this change and it was merged. ( https://gerrit.osmocom.org/12135 )

Change subject: Trap handlers: always log to stdout
......................................................................

Trap handlers: always log to stdout

Since the scripts are intended to be used as systemd services, there's
no need in separate logging via syslog: systemd will take care of
properly collecting and storing script output. Hence we can drop extra
options and function parameters.

Change-Id: Ifcad1877d45d43b3a2e617775a1c9b256e190591
Related: SYS#4399
---
M contrib/systemd/osmo-ctrl2cgi.service
M osmopy/trap_helper.py
M scripts/ctrl2cgi.py
M scripts/soap.py
4 files changed, 5 insertions(+), 9 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Pau Espin Pedrol: Looks good to me, approved



diff --git a/contrib/systemd/osmo-ctrl2cgi.service b/contrib/systemd/osmo-ctrl2cgi.service
index 8563c66..f82e1e9 100644
--- a/contrib/systemd/osmo-ctrl2cgi.service
+++ b/contrib/systemd/osmo-ctrl2cgi.service
@@ -4,7 +4,7 @@
 [Service]
 Type=simple
 Restart=always
-ExecStart=/usr/bin/ctrl2cgi.py -o -d -c /etc/osmocom/ctrl2cgi.ini
+ExecStart=/usr/bin/ctrl2cgi.py -d -c /etc/osmocom/ctrl2cgi.ini
 RestartSec=2
 
 [Install]
diff --git a/osmopy/trap_helper.py b/osmopy/trap_helper.py
index d4a3b75..45dc527 100644
--- a/osmopy/trap_helper.py
+++ b/osmopy/trap_helper.py
@@ -95,7 +95,7 @@
             sys.argv.remove(dbg2)
     os.execl(path, script, *sys.argv[1:])
 
-def debug_init(name, is_debug, output):
+def debug_init(name, is_debug):
     """
     Initialize signal handlers and logging
     """
@@ -104,9 +104,7 @@
         log.setLevel(logging.DEBUG)
     else:
         log.setLevel(logging.INFO)
-    log.addHandler(logging.handlers.SysLogHandler('/dev/log'))
-    if output:
-        log.addHandler(logging.StreamHandler(sys.stdout))
+    log.addHandler(logging.StreamHandler(sys.stdout))
 
     reboot = partial(reloader, os.path.abspath(__file__), os.path.basename(__file__), log, '-d', '--debug') # keep in sync with caller's add_argument()
     signal.signal(signal.SIGHUP, reboot)
diff --git a/scripts/ctrl2cgi.py b/scripts/ctrl2cgi.py
index 1d6813d..0551520 100755
--- a/scripts/ctrl2cgi.py
+++ b/scripts/ctrl2cgi.py
@@ -148,13 +148,12 @@
     p.add_argument('-p', '--port-ctrl', type=int, default=4250, help="Port to use for CTRL interface, defaults to 4250")
     p.add_argument('-n', '--num-max-conn', type=int, default=5, help="Max number of concurrent HTTP requests to CGI server")
     p.add_argument('-d', '--debug', action='store_true', help="Enable debug log") # keep in sync with debug_init call below
-    p.add_argument('-o', '--output', action='store_true', help="Log to STDOUT in addition to SYSLOG")
     p.add_argument('-l', '--location', help="Location URL of the CGI server")
     p.add_argument('-s', '--secret-key', help="Secret key used to generate verification token")
     p.add_argument('-c', '--config-file', help="Path Config file. Cmd line args override values in config file")
     args = p.parse_args()
 
-    log = debug_init('CTRL2CGI', args.debug, args.output)
+    log = debug_init('CTRL2CGI', args.debug)
 
     location_cfgfile = None
     secret_key_cfgfile = None
diff --git a/scripts/soap.py b/scripts/soap.py
index 267b4d8..0534000 100755
--- a/scripts/soap.py
+++ b/scripts/soap.py
@@ -136,11 +136,10 @@
     p.add_argument('-w', '--wsdl', required=True, help="WSDL URL for SOAP")
     p.add_argument('-n', '--num', type=int, default=5, help="Max number of concurrent HTTP requests to SOAP server")
     p.add_argument('-d', '--debug', action='store_true', help="Enable debug log") # keep in sync with debug_init call below
-    p.add_argument('-o', '--output', action='store_true', help="Log to STDOUT in addition to SYSLOG")
     p.add_argument('-l', '--location', help="Override location found in WSDL file (don't use unless you know what you're doing)")
     args = p.parse_args()
 
-    log = debug_init('CTRL2SOAP', args.debug, args.output)
+    log = debug_init('CTRL2SOAP', args.debug)
 
     log.info("SOAP proxy %s starting with PID %d ..." % (__version__, os.getpid()))
     reactor.connectTCP(args.ctrl, args.port, TrapFactory(args.ctrl, args.port, Trap, defer.DeferredSemaphore(args.num), log, args.wsdl, args.location))

-- 
To view, visit https://gerrit.osmocom.org/12135
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifcad1877d45d43b3a2e617775a1c9b256e190591
Gerrit-Change-Number: 12135
Gerrit-PatchSet: 2
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181205/c7af90c8/attachment.htm>


More information about the gerrit-log mailing list