Skip to content
Snippets Groups Projects
Commit f0977a68 authored by juga's avatar juga Committed by Matt Traudt
Browse files

Add possibility to log to system log

Since sbws migth be run as a system service, it should give some
information to the system log.
There are no new options to configure for the user, and it's
disabled by default.
parent c0e69450
No related branches found
No related tags found
No related merge requests found
......@@ -87,6 +87,8 @@ min_relays = 50
to_file = yes
# Whether or not to log to stdout
to_stdout = no
# Whether or not to log to syslog
to_syslog = no
# If logging to file, how large (in bytes) should the file be allowed to get
# before rotating to a new one. 10485760 is 10 MiB. If zero or number of
# backups is zero, never rotate the log file.
......
......@@ -2,10 +2,10 @@
keys = root,sbws
[handlers]
keys = to_file,to_stdout
keys = to_file,to_stdout,to_syslog
[formatters]
keys = to_file,to_stdout
keys = to_file,to_stdout,to_syslog
[logger_root]
level = WARNING
......@@ -27,20 +27,18 @@ class = handlers.RotatingFileHandler
formatter = to_file
args = ('/dev/null', )
## for logging to system log
#[handler_to_syslog]
#class=handlers.SysLogHandler
#formatter=to_syslog
#level = INFO
#args = ()
# for logging to system log
[handler_to_syslog]
class=handlers.SysLogHandler
formatter=to_syslog
level = INFO
args = ('/dev/log',)
[formatter_to_stdout]
[formatter_to_file]
## syslog-like formater
#[formatter_to_syslog]
## hostname should be added here with a context filter, dunno if there is a way
## to add it here
#format = %(asctime)s %(module)s[%(process)s]: <%(levelname)s> %(message)s
#datefmt = %b %d %H:%M:%S
# syslog-like formatter
[formatter_to_syslog]
format = %(asctime)s %(module)s[%(process)s]: <%(levelname)s> %(message)s
datefmt = %b %d %H:%M:%S
......@@ -109,6 +109,8 @@ def configure_logging(args, conf):
handlers.add('to_stdout')
if can_log_to_file and conf.getboolean('logging', 'to_file'):
handlers.add('to_file')
if conf.getboolean('logging', 'to_syslog'):
handlers.add('to_syslog')
# Collect the handlers in the appropriate config option
conf[logger]['handlers'] = ','.join(handlers)
if 'to_file' in handlers:
......@@ -286,6 +288,7 @@ def _validate_logging(conf):
bools = {
'to_file': {},
'to_stdout': {},
'to_syslog': {},
}
ints = {
'to_file_max_bytes': {'minimum': 0, 'maximum': None},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment