Added filemode support to setupLogger.

This allows log files to be appended to if desired.
This commit is contained in:
John Garland 2009-05-17 12:28:03 +00:00
commit 100227f4e1

View file

@ -34,7 +34,7 @@ levels = {
"none": logging.CRITICAL, "none": logging.CRITICAL,
"debug": logging.DEBUG "debug": logging.DEBUG
} }
def setupLogger(level="error", filename=None): def setupLogger(level="error", filename=None, filemode="w"):
""" """
Sets up the basic logger and if `:param:filename` is set, then it will log Sets up the basic logger and if `:param:filename` is set, then it will log
to that file instead of stdout. to that file instead of stdout.
@ -51,7 +51,7 @@ def setupLogger(level="error", filename=None):
format="[%(levelname)-8s] %(asctime)s %(module)s:%(lineno)d %(message)s", format="[%(levelname)-8s] %(asctime)s %(module)s:%(lineno)d %(message)s",
datefmt="%H:%M:%S", datefmt="%H:%M:%S",
filename=filename, filename=filename,
filemode="w" filemode=filemode
) )
def setLoggerLevel(level): def setLoggerLevel(level):