irkerd: Add the --syslog argument to swap in the SysLogHandler syslog
authorW. Trevor King <wking@tremily.us>
Sat, 8 Mar 2014 00:39:35 +0000 (16:39 -0800)
committerW. Trevor King <wking@tremily.us>
Wed, 19 Mar 2014 17:26:21 +0000 (10:26 -0700)
For folks running irkerd as a daemon, it's useful to use a real log
handler ;).

NEWS
irkerd
irkerd.xml

diff --git a/NEWS b/NEWS
index 15ca4613a06289f3536960794ad129695068972c..672259b5bfb3d3de9f229c8d742c962dec6b69b1 100644 (file)
--- 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 790a2560add04ea0cc0e9b1717b6e86b34962b06..e2339273c96b6c790097e9de1cd1d2156ad53147 100755 (executable)
--- 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())
index caf36af532aa6cdb648b3936b9add8a04cf60773..f6cf2771ba5b470fc1660714df5474ab5bcc6b9a 100644 (file)
@@ -20,6 +20,7 @@
   <command>irkerd</command>
      <arg>-c <replaceable>ca-file</replaceable></arg>
      <arg>-d <replaceable>debuglevel</replaceable></arg>
+     <arg>--syslog</arg>
      <arg>-l <replaceable>logfile</replaceable></arg>
      <arg>-n <replaceable>nick</replaceable></arg>
      <arg>-p <replaceable>password</replaceable></arg>
@@ -113,6 +114,11 @@ it. This option will generally only be of interest to developers;
 consult the source code for details.</para></listitem>
 </varlistentry>
 <varlistentry>
+<term>--syslog</term>
+<listitem><para>Writes debugging ouput to syslog (via /dev/log)
+instead of printing to stderr.</para></listitem>
+</varlistentry>
+<varlistentry>
 <term>-l</term>
 <listitem><para>Takes a following filename, logs traffic to that file.
 Each log line consists of three |-separated fields; a numeric