Skip to content
Snippets Groups Projects
Commit d48609c2 authored by Eric S. Raymond's avatar Eric S. Raymond
Browse files

Portability fix: work with BSD as well as Linux log device.

parent 647cbea9
No related branches found
No related tags found
No related merge requests found
irker history
Repository head:
With -i, message string argument now optional, stdin is read if it is absent.
Auto-adapt to BSD & OS X log device as well as Linux's.
2.10: 2014-06-19
irk no longer fails on ircs channel URLs.
......
......@@ -47,6 +47,7 @@ import logging
import logging.handlers
import json
import os
import os.path
try: # Python 3
import queue
except ImportError: # Python 2
......@@ -980,7 +981,13 @@ if __name__ == '__main__':
args = parser.parse_args()
if not args.log_file and in_background():
handler = logging.handlers.SysLogHandler(address='/dev/log',
# The Linux and BSD values of the logging device
logdev = [x for x in ('/dev/log', '/var/run/syslog')
if os.path.exists(x)]
if len(logdev) != 1:
sys.stderr.write("can't initialize log device, bailing out!\n")
raise SystemExit(1)
handler = logging.handlers.SysLogHandler(address=logdev[0],
facility='daemon')
else:
handler = logging.StreamHandler()
......
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