From 672240ab1bafa75503618a1e3993eda9c85a5fde Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 31 May 2014 09:24:09 -0400 Subject: [PATCH] Use syslog facility when irkerd is backgtrounded and no -l was given. --- NEWS | 3 +++ irkerd | 12 +++++++++++- irkerd.xml | 9 +++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index cddd917..472573d 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ irker history +Repository head: + If irkerd is running in background, log to /dev/syslog (facility daemon). + 2.8: 2014-05-30 Various minor improvements to irk. Cope better with branch names containing slashes. diff --git a/irkerd b/irkerd index 9e51549..f7adadc 100755 --- a/irkerd +++ b/irkerd @@ -42,8 +42,10 @@ CONNECTION_MAX = 200 # To avoid hitting a thread limit version = "2.8" +import os import argparse import logging +import logging.handlers import json try: # Python 3 import queue @@ -933,6 +935,9 @@ class IrkerUDPHandler(socketserver.BaseRequestHandler): line = UNICODE_TYPE(line, 'utf-8') irker.handle(line=line.strip()) +def in_background(): + "Is this process running in background?" + return os.getpgrp() != os.tcgetpgrp(1) if __name__ == '__main__': parser = argparse.ArgumentParser( @@ -965,7 +970,12 @@ if __name__ == '__main__': help='message for --immediate mode') args = parser.parse_args() - handler = logging.StreamHandler() + if not args.log_file and in_background(): + 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..d9de17f 100644 --- a/irkerd.xml +++ b/irkerd.xml @@ -108,8 +108,9 @@ joining a channel to log its traffic. -d -Takes a following value, setting the debugging level from -it. This option will generally only be of interest to developers; +Takes a following value, setting the debugging level +from it; possible values are 'critical', 'error', 'warning', 'info', +'debug'. This option will generally only be of interest to developers; consult the source code for details. @@ -149,6 +150,10 @@ terminate. +If no is set, logging will be to stndard +output (if irkerd is running in foreground) +or to /dev/syslog with facility "daemon" (if +irkerd is running in packground). LIMITATIONS -- 2.26.2