Beispiel #1
0
def get_logger(name=None):
    conn = dbutil.get_dbconn()
    logger = logging.getLogger(name)
    logger.setLevel(conf.get_log_root_level())
    consoleFormatter = logging.Formatter(conf.get_log_console_format())
    consoleHandler = logging.StreamHandler()
    consoleHandler.setLevel(conf.get_log_console_level())
    consoleHandler.setFormatter(consoleFormatter)
    logger.addHandler(consoleHandler)
     
    dbFormatter = logging.Formatter(conf.get_log_db_format())
    dbHandler = DBHandler(conn)
    dbHandler.setLevel(conf.get_log_db_level())
    dbHandler.setFormatter(dbFormatter)
    logger.addHandler(dbHandler)
    return logger
Beispiel #2
0
 def _get_conn(cls, conn):
     if conn is None:
         return dbutil.get_dbconn()
     else:
         return conn