modified the logging to comply with what is on the docs.python.org page on the logging library and how it should be used

This commit is contained in:
sm
2011-03-22 11:10:19 -06:00
parent 2c07c3ba45
commit 05d1b962fc
5 changed files with 25 additions and 32 deletions
+2 -28
View File
@@ -1,36 +1,10 @@
import os
import logging
import logging.handlers
import inspect
import numpy as np
def get_logger(filename, level = logging.DEBUG, logger_name = 'interp', size = 2048, backupCount = 10):
"""
This is a simple wrapper around a few sane
defaults using Python's logging functionality.
An explaination of the optional parameters:
filename : the filename
level : one of either debug, info, warn, or error
logger_name : if one needs multiple logfiles, one must name them.
size : the size in bytes of the logfile before roll (defaults to 2MB)
backupCount : number of rolled logs to keep around (defaults to 10)
"""
logger = logging.getLogger(logger_name)
logger.setLevel(level)
my_format = logging.Formatter('%(asctime)s %(levelname)s (%(process)d) %(filename)s %(funcName)s:%(lineno)d %(message)s')
handler = logging.handlers.RotatingFileHandler(
filename, maxBytes = size * 1024, backupCount = backupCount)
handler.setFormatter(my_format)
logger.addHandler(handler)
return logger
log = get_logger(filename = '/tmp/interp.log', level = logging.INFO, size = 10240)
import logging
log = logging.getLogger("interp")
def rms(errors):
"""