From 1c8e2a07d85f45d94437dbedeffeafa9b000b525 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Thu, 29 Oct 2020 11:05:45 -0400 Subject: [PATCH] Local builds: buffer up initial logs and replay to the module build file Logging during a build that occurs before the build directory is created used to be logged to the console, but not retained in the build log file. This made referring to the build log file confusing. Solve this by buffering logs in memory until the log file is created and replaying them. A little bit of hackery is needed to avoid saving dangling references to libsolv objects. --- module_build_service/common/logger.py | 73 ++++++++++++++++++++++++++- module_build_service/manage.py | 6 ++- 2 files changed, 77 insertions(+), 2 deletions(-) diff --git a/module_build_service/common/logger.py b/module_build_service/common/logger.py index 3b47c39f..b8fea378 100644 --- a/module_build_service/common/logger.py +++ b/module_build_service/common/logger.py @@ -22,6 +22,7 @@ logging.warning("%s failed to build", task_id) from __future__ import absolute_import import os import logging +import logging.handlers import inspect levels = { @@ -65,6 +66,47 @@ class ModuleBuildFileHandler(logging.FileHandler): logging.FileHandler.emit(self, record) +def _is_solv_object(o): + """ + Returns true if the object is a libsolv object or contains one. + (Contains is implemented pragmatically and might need to be extended) + """ + if isinstance(o, (tuple, list)): + return any(_is_solv_object(x) for x in o) + else: + return str(type(o)).startswith("