mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat: support LOG_CONFIG environment variable
This variable allows users to override the logging.conf used for Python logging configuration. By default, this is set to logging.conf, which is a production config. LOG_CONFIG is treated relative to [options] aurwebdir. This patch allows us to specify the logging config as opposed to copying over logging.conf in our test docker and gitlab test scripts, as well as ease-of-testing as a developer. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
7f1de72e08
commit
7bcc8d7ce7
6 changed files with 16 additions and 12 deletions
|
@ -4,8 +4,11 @@ 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")
|
||||
config_path = os.path.join(aurwebdir, "logging.conf")
|
||||
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())
|
||||
|
@ -19,4 +22,5 @@ def get_logger(name: str) -> logging.Logger:
|
|||
: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