Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python import syslog on windows

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.

like image 763
Sean Keane Avatar asked Aug 27 '14 21:08

Sean Keane


1 Answers

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
like image 93
vav Avatar answered Oct 14 '22 06:10

vav