Changeset View
Changeset View
Standalone View
Standalone View
pykolab/logger.py
Show All 21 Lines | |||||
import logging.handlers | import logging.handlers | ||||
import os | import os | ||||
import pwd | import pwd | ||||
import sys | import sys | ||||
import time | import time | ||||
from pykolab.translate import _ | from pykolab.translate import _ | ||||
class StderrToLogger(object): | |||||
""" | |||||
Fake file-like stream object that redirects writes to a logger instance. | |||||
""" | |||||
def __init__(self, logger, log_level=logging.DEBUG): | |||||
self.logger = logger | |||||
self.log_level = log_level | |||||
self.linebuf = '' | |||||
def write(self, buf): | |||||
for line in buf.rstrip().splitlines(): | |||||
self.logger.log(self.log_level, line.rstrip()) | |||||
def flush(self): | |||||
pass | |||||
class Logger(logging.Logger): | class Logger(logging.Logger): | ||||
""" | """ | ||||
The PyKolab version of a logger. | The PyKolab version of a logger. | ||||
This class wraps the Python native logging library, adding to the | This class wraps the Python native logging library, adding to the | ||||
loglevel capabilities, a debuglevel capability. | loglevel capabilities, a debuglevel capability. | ||||
""" | """ | ||||
debuglevel = 0 | debuglevel = 0 | ||||
▲ Show 20 Lines • Show All 182 Lines • Show Last 20 Lines |