flaschengeist/geruecht/logger.py

21 lines
594 B
Python

import logging
from logging.handlers import WatchedFileHandler
import sys
FORMATTER = logging.Formatter("%(asctime)s%(name)s%(levelname)s%(message)s")
logFileHandler = WatchedFileHandler("testlog.log")
logFileHandler.setFormatter(FORMATTER)
logStreamHandler = logging.StreamHandler(stream=sys.stdout)
logStreamHandler.setFormatter(FORMATTER)
def getLogger(logger_name):
logger = logging.getLogger(logger_name)
logger.setLevel(logging.DEBUG)
logger.addHandler(logFileHandler)
logger.addHandler(logStreamHandler)
logger.propagate = False
return logger