granite-guardian / logger.py
grahamwhiteuk's picture
feat: move code to root dir
6d2cabd verified
raw
history blame contribute delete
412 Bytes
import logging
logger = logging.getLogger("demo")
logger.setLevel(logging.DEBUG)
stream_handler = logging.StreamHandler()
stream_handler.setLevel(logging.DEBUG)
logger.addHandler(stream_handler)
file_handler = logging.FileHandler("logs.txt")
file_handler.setFormatter(
logging.Formatter("%(asctime)s - %(filename)s:%(lineno)d - %(message)s", datefmt="%Y-%m-%d %H:%M:%S")
)
logger.addHandler(file_handler)