mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
chore: rename logging.py and redis.py to avoid circular imports
Signed-off-by: Leonidas Spyropoulos <artafinde@archlinux.org>
This commit is contained in:
parent
b757e66997
commit
9c0f8f053e
32 changed files with 72 additions and 73 deletions
26
aurweb/aur_logging.py
Normal file
26
aurweb/aur_logging.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
import logging
|
||||
import logging.config
|
||||
import os
|
||||
|
||||
import aurweb.config
|
||||
|
||||
# For testing, users should set LOG_CONFIG=logging.test.conf
|
||||
# We test against various debug log output.
|
||||
aurwebdir = aurweb.config.get("options", "aurwebdir")
|
||||
log_config = os.environ.get("LOG_CONFIG", "logging.conf")
|
||||
config_path = os.path.join(aurwebdir, log_config)
|
||||
|
||||
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)
|
Loading…
Add table
Add a link
Reference in a new issue