Untitled

mail@pastecode.io avatar
unknown
plain_text
24 days ago
686 B
1
Indexable
Never
import logging
import sys


def configure_logging(log_filename):
    logFormatter = logging.Formatter(
        "%(asctime)s %(levelname)s %(threadName)s - %(module)s.%(funcName)s %(lineno)d - %(message)s")

    logger = logging.getLogger("cew")
    logger.setLevel(logging.DEBUG)

    file_handler = logging.FileHandler(log_filename)
    file_handler.setFormatter(logFormatter)
    file_handler.setLevel(logging.DEBUG)

    stream_handler = logging.StreamHandler(stream=sys.stdout)
    stream_handler.setFormatter(logFormatter)
    stream_handler.setLevel(logging.DEBUG)

    logger.addHandler(file_handler)
    logger.addHandler(stream_handler)

    return logger
Leave a Comment