From: W. Trevor King Date: Sat, 8 Mar 2014 00:39:35 +0000 (-0800) Subject: irkerd: Add the --syslog argument to swap in the SysLogHandler X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=add6195cf2350f61731f13ea3c8b6c3e27f9270a;p=irker.git irkerd: Add the --syslog argument to swap in the SysLogHandler For folks running irkerd as a daemon, it's useful to use a real log handler ;). --- diff --git a/NEWS b/NEWS index 15ca461..672259b 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ irker history +2.8 @ unreleased + Add support for --syslog. + 2.7 @ 2014-03-15 Add support for ircs:// and SSL/TLS connections to IRC servers. Add support for per-URL usernames and passwords. diff --git a/irkerd b/irkerd index 790a256..e233927 100755 --- a/irkerd +++ b/irkerd @@ -44,6 +44,7 @@ version = "2.7" import argparse import logging +import logging.handlers import json try: # Python 3 import queue @@ -943,6 +944,9 @@ if __name__ == '__main__': parser.add_argument( '-d', '--log-level', metavar='LEVEL', choices=LOG_LEVELS, help='file of trusted certificates for SSL/TLS') + parser.add_argument( + '--syslog', action='store_const', const=True, + help='log irkerd action to syslog instead of stderr') parser.add_argument( '-l', '--log-file', metavar='PATH', help='file for saving captured message traffic') @@ -965,7 +969,11 @@ if __name__ == '__main__': help='message for --immediate mode') args = parser.parse_args() - handler = logging.StreamHandler() + if args.syslog: + handler = logging.handlers.SysLogHandler( + address='/dev/log', facility='daemon') + else: + handler = logging.StreamHandler() LOG.addHandler(handler) if args.log_level: log_level = getattr(logging, args.log_level.upper()) diff --git a/irkerd.xml b/irkerd.xml index caf36af..f6cf277 100644 --- a/irkerd.xml +++ b/irkerd.xml @@ -20,6 +20,7 @@ irkerd -c ca-file -d debuglevel + --syslog -l logfile -n nick -p password @@ -113,6 +114,11 @@ it. This option will generally only be of interest to developers; consult the source code for details. +--syslog +Writes debugging ouput to syslog (via /dev/log) +instead of printing to stderr. + + -l Takes a following filename, logs traffic to that file. Each log line consists of three |-separated fields; a numeric