1 import logging, logging.handlers, syslog, os
6 import __main__ as main
7 self.name = os.path.basename(main.__file__)
8 self.logger = logging.getLogger(self.name)
9 self.logger.setLevel(logging.INFO)
10 self.handler = logging.handlers.SysLogHandler(address = '/dev/log', facility = logging.handlers.SysLogHandler.LOG_LOCAL0)
11 self.logger.addHandler(self.handler)
13 thestr = "%s[%d]: %s" % (self.name,os.getpid(),what)
15 self.logger.info(thestr)
23 # Threaded callback class
24 class ThreadFunction():
28 def __init__(self, f):
30 self._q = queue.Queue()
31 self._t = threading.Thread(target=self._thread_func)
34 def _thread_func(self):
36 (cmd, data) = self._q.get()
44 raise NotImplementedError("Command %d does not exist" % cmd)
46 def __call__(self, *arg):
47 self._q.put((self._CALL, arg))
50 self._q.put((_TERM, None))