diff options
author | David Sommerseth <dazo@users.sourceforge.net> | 2013-12-26 00:11:37 +0100 |
---|---|---|
committer | David Sommerseth <dazo@users.sourceforge.net> | 2013-12-26 00:22:32 +0100 |
commit | 1e97c1c6537724fc3f4866da06b1e380471c1c06 (patch) | |
tree | b161f348c4b8c380e1d0fcc2320c5fc2d889871e /LogActio | |
parent | 8655f934aabe1ba64668cb9dfff6e3e65e79083a (diff) | |
download | logactio-1e97c1c6537724fc3f4866da06b1e380471c1c06.tar.gz logactio-1e97c1c6537724fc3f4866da06b1e380471c1c06.tar.xz logactio-1e97c1c6537724fc3f4866da06b1e380471c1c06.zip |
Added logging to stdout
Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Diffstat (limited to 'LogActio')
-rw-r--r-- | LogActio/Logger.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/LogActio/Logger.py b/LogActio/Logger.py index 692f36f..a160f12 100644 --- a/LogActio/Logger.py +++ b/LogActio/Logger.py @@ -28,6 +28,7 @@ import syslog LOGTYPE_FILE = 0 LOGTYPE_SYSLOG = 1 +LOGTYPE_STDOUT = 2 class FileLogger(object): def __init__(self, logfile): @@ -57,6 +58,20 @@ class SysLogger(object): syslog.closelog() +class StdoutLogger(object): + def __init__(self): + import sys + self.__logf = sys.stdout + + + def _log(self, lvl, msg): + self.__logf.write("[%i] %s\n" % (lvl, msg)) + self.__logf.flush() + + + def _close(self): + pass + class Logger(object): def __init__(self, logtype, logdest, verblvl): @@ -65,6 +80,8 @@ class Logger(object): self.__logger = FileLogger(logdest) elif logtype == LOGTYPE_SYSLOG: self.__logger = SysLogger(logdest) + elif logtype == LOGTYPE_STDOUT: + self.__logger = StdoutLogger() def Log(self, lvl, msg): if lvl <= self.__verblevel: |