I have a python script that is normally run on a unix machine, I am trying to run it on windows. The one snag I have run into is the module syslog. Is there a way that anyone knows that I can get around this on a windows machine, is there an equivalent package for windows? Running python 2.7.
Asked
Active
Viewed 8,796 times
10
-
https://docs.python.org/2/library/syslog.html – Sean Keane Aug 27 '14 at 21:46
-
You don't need to add comments to your own post - just modify your question. – vav Dec 26 '14 at 20:47
2 Answers
12
You can create syslog.py and put it somewhere in a python path. You also can customize it to actually write messages down or send them over network.
My version below. (It misses few functions and constants, so you may need to add some more):
import sys
LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, \
LOG_NOTICE, LOG_INFO, LOG_DEBUG = range(8)
LOG_KERN, LOG_USER, LOG_MAIL, LOG_DAEMON, LOG_AUTH, \
LOG_SYSLOG, LOG_LPR, LOG_NEWS, LOG_UUCP = range(0,65,8)
LOG_CRON = 120
LOG_LOCAL0 = 128
LOG_LOCAL1 = 136
LOG_LOCAL2 = 144
LOG_LOCAL3 = 152
LOG_LOCAL4 = 160
LOG_LOCAL5 = 168
LOG_LOCAL6 = 176
LOG_LOCAL7 = 184
LOG_PID = 1
LOG_CONS = 2
LOG_NDELAY = 8
LOG_NOWAIT = 16
def syslog(message):
pass
def syslog(priority, message):
pass
def openlog(ident=sys.argv[0], logoptions=0, facility=LOG_USER):
pass
def closelog():
pass
def setlogmask(maskpri):
pass

vav
- 4,584
- 2
- 19
- 39
1
The "logging" module should be ideal for what you're looking for, though it may require some rewriting of the code. It also has the advantage that logging is platform independent, so it works on both Windows and *nix, which is always handy.

Phillammon
- 184
- 6
-
I was hoping to find a solution that didn't involve rewriting the code as this scenario is just for developing on windows locally. It is normally run on linux. And from running into this module import issue I currently don't see a way around that. – Sean Keane Sep 02 '14 at 22:46