mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
After actually digging into how the logger does things, since the root logger is required and we have specific level-changing loggers for our components, we must no-op the root logger to avoid it duplicating logs from the others. Signed-off-by: Kevin Morris <kevr@0cost.org>
22 lines
680 B
Python
22 lines
680 B
Python
import logging
|
|
import logging.config
|
|
import os
|
|
|
|
import aurweb.config
|
|
|
|
aurwebdir = aurweb.config.get("options", "aurwebdir")
|
|
config_path = os.path.join(aurwebdir, "logging.conf")
|
|
|
|
logging.config.fileConfig(config_path, disable_existing_loggers=False)
|
|
logging.getLogger("root").addHandler(logging.NullHandler())
|
|
|
|
|
|
def get_logger(name: str) -> logging.Logger:
|
|
""" A logging.getLogger wrapper. Importing this function and
|
|
using it to get a module-local logger ensures that logging.conf
|
|
initialization is performed wherever loggers are used.
|
|
|
|
:param name: Logger name; typically `__name__`
|
|
:returns: name's logging.Logger
|
|
"""
|
|
return logging.getLogger(name)
|