mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
centralize logging initialization
so it can be shared across modules
This commit is contained in:
19
tljh/log.py
Normal file
19
tljh/log.py
Normal file
@@ -0,0 +1,19 @@
|
||||
"""Setup tljh logging"""
|
||||
import os
|
||||
import logging
|
||||
|
||||
from .config import INSTALL_PREFIX
|
||||
|
||||
|
||||
def init_logging():
|
||||
"""Setup default tljh logger"""
|
||||
logger = logging.getLogger("tljh")
|
||||
os.makedirs(INSTALL_PREFIX, exist_ok=True)
|
||||
file_logger = logging.FileHandler(os.path.join(INSTALL_PREFIX, "installer.log"))
|
||||
file_logger.setFormatter(logging.Formatter("%(asctime)s %(message)s"))
|
||||
logger.addHandler(file_logger)
|
||||
|
||||
stderr_logger = logging.StreamHandler()
|
||||
stderr_logger.setFormatter(logging.Formatter("%(message)s"))
|
||||
logger.addHandler(stderr_logger)
|
||||
logger.setLevel(logging.INFO)
|
||||
Reference in New Issue
Block a user