Skip to content

Commit 8aa4922

Browse files
committed
Remove dependency on syslog module -- it won't be available under Python 2.7 under Windows.
- Legacy-Id: 4974
1 parent de5da28 commit 8aa4922

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

ietf/settings.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
# http://code.djangoproject.com/wiki/SplitSettings
66

77
import os
8-
import syslog
9-
syslog.openlog("datatracker", syslog.LOG_PID, syslog.LOG_USER)
8+
try:
9+
import syslog
10+
syslog.openlog("datatracker", syslog.LOG_PID, syslog.LOG_USER)
11+
except ImportError:
12+
pass
1013

1114
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
1215

ietf/utils/log.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Copyright The IETF Trust 2007, All Rights Reserved
22

3-
import syslog
3+
try:
4+
import syslog
5+
write = syslog.syslog
6+
except ImportError: # import syslog will fail on Windows boxes
7+
import sys
8+
write = lambda x: sys.stderr.write(x+"\n")
9+
410
import inspect
511
import os.path
612
import ietf
@@ -33,6 +39,6 @@ def log(msg):
3339
where = " in " + func + "()"
3440
except IndexError:
3541
file, line, where = "/<UNKNOWN>", 0, ""
36-
syslog.syslog("ietf%s(%d)%s: %s" % (file, line, where, msg))
42+
write("ietf%s(%d)%s: %s" % (file, line, where, msg))
3743

3844
log("IETFdb v%s started" % ietf.__version__)

0 commit comments

Comments
 (0)