Commit a8d88006 authored by Ad Schellevis's avatar Ad Schellevis

(configd) make syslog for Daemonize() optional

parent f903f986
...@@ -103,12 +103,18 @@ if len(sys.argv) > 1 and 'console' in sys.argv[1:]: ...@@ -103,12 +103,18 @@ if len(sys.argv) > 1 and 'console' in sys.argv[1:]:
else: else:
proc_handler.run() proc_handler.run()
else: else:
# bind log handle to syslog to catch messages from Daemonize() syslog_socket = "/var/run/log"
loghandle = logging.getLogger("configd.py") if os.path.exists(syslog_socket):
loghandle.setLevel(logging.INFO) # bind log handle to syslog to catch messages from Daemonize()
handler = logging.handlers.SysLogHandler(address="/var/run/log", facility=logging.handlers.SysLogHandler.LOG_DAEMON) # (if syslog facility is active)
handler.setFormatter(logging.Formatter("%(name)s %(message)s")) loghandle = logging.getLogger("configd.py")
loghandle.addHandler(handler) loghandle.setLevel(logging.INFO)
handler = logging.handlers.SysLogHandler(address=syslog_socket,
facility=logging.handlers.SysLogHandler.LOG_DAEMON)
handler.setFormatter(logging.Formatter("%(name)s %(message)s"))
loghandle.addHandler(handler)
else:
loghandle = None
# daemonize process # daemonize process
daemon = Daemonize(app=__file__.split('/')[-1].split('.py')[0], daemon = Daemonize(app=__file__.split('/')[-1].split('.py')[0],
pid=cnf.get('main','pid_filename'), pid=cnf.get('main','pid_filename'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment