Added logging to stdout

This commit is contained in:
SG
2025-06-05 18:14:35 +03:00
parent 36855fe7fb
commit 12c9f5f296
2 changed files with 27 additions and 5 deletions

View File

@@ -1,6 +1,24 @@
import os
import logging, os, sys
# Main config section
class Config:
APP_NAME = "hydrogen"
MAIN_PAGE_TITLE = "Selected poems"
CONTENT_DIR = os.environ.get('CONTENT_DIR') or 'content'
OUTPUT_DIR = os.environ.get('OUTPUT_DIR') or 'public'
HEADER_IMAGE = 'static/header.jpg'
LOG_TO = sys.stdout
LOG_LEVEL = logging.DEBUG
# Logging config section
logger = logging.getLogger(Config.APP_NAME)
logger.setLevel(Config.LOG_LEVEL)
stdout_handler = logging.StreamHandler(Config.LOG_TO)
stdout_handler.setLevel(Config.LOG_LEVEL)
formatter = logging.Formatter(
'[%(asctime)s] %(name)s: %(levelname)s: %(message)s',
datefmt='%Y-%m-%d %H:%M:%S'
)
stdout_handler.setFormatter(formatter)
if not logger.hasHandlers():
logger.addHandler(stdout_handler)
logger.propagate = False