mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-13 21:39:59 +08:00
Set an explicit log level on our per-build file handler.
This is a bit of a stab in the dark. In some environments, our build.log files have little to no contents. This might be because we don't have an explicit log level set, but maybe not.
This commit is contained in:
@@ -128,7 +128,11 @@ def notfound_error(e):
|
||||
|
||||
init_logging(conf)
|
||||
log = getLogger(__name__)
|
||||
build_logs = ModuleBuildLogs(conf.build_logs_dir, conf.build_logs_name_format)
|
||||
build_logs = ModuleBuildLogs(
|
||||
conf.build_logs_dir,
|
||||
conf.build_logs_name_format,
|
||||
conf.log_level,
|
||||
)
|
||||
|
||||
|
||||
def get_url_for(*args, **kwargs):
|
||||
|
||||
@@ -87,7 +87,7 @@ class ModuleBuildLogs(object):
|
||||
"""
|
||||
Manages ModuleBuildFileHandler logging handlers.
|
||||
"""
|
||||
def __init__(self, build_logs_dir, build_logs_name_format):
|
||||
def __init__(self, build_logs_dir, build_logs_name_format, level=logging.INFO):
|
||||
"""
|
||||
Creates new ModuleBuildLogs instance. Module build logs are stored
|
||||
to `build_logs_dir` directory.
|
||||
@@ -95,6 +95,7 @@ class ModuleBuildLogs(object):
|
||||
self.handlers = {}
|
||||
self.build_logs_dir = build_logs_dir
|
||||
self.build_logs_name_format = build_logs_name_format
|
||||
self.level = level
|
||||
|
||||
def path(self, build):
|
||||
"""
|
||||
@@ -122,8 +123,10 @@ class ModuleBuildLogs(object):
|
||||
|
||||
# Create and add ModuleBuildFileHandler.
|
||||
handler = ModuleBuildFileHandler(build.id, self.path(build))
|
||||
handler.setLevel(self.level)
|
||||
handler.setFormatter(logging.Formatter(log_format, None))
|
||||
log = logging.getLogger()
|
||||
log.setLevel(self.level)
|
||||
log.addHandler(handler)
|
||||
|
||||
self.handlers[build.id] = handler
|
||||
|
||||
@@ -88,7 +88,8 @@ class TestLogger(unittest.TestCase):
|
||||
self.assertTrue(os.path.exists(path))
|
||||
with open(path, "r") as f:
|
||||
data = f.read()
|
||||
for level in ["DEBUG", "INFO", "WARNING", "ERROR"]:
|
||||
# Note that DEBUG is not present unless configured server-wide.
|
||||
for level in ["INFO", "WARNING", "ERROR"]:
|
||||
self.assertTrue(data.find("%s - ignore this test msg1" % level) != -1)
|
||||
|
||||
# Try to log more messages when build_log for module 1 is stopped.
|
||||
|
||||
Reference in New Issue
Block a user