monitor: log start/stop of stages and pipelines too

Generate log messages with origin "org.osbuild.main" when
pipelines/stages start and finish. This way a higher level
frontend can display high level progress coming from this
origin and filter out e.g. stages based log messages (that
are usually quite technical as they are just stdout/stderr
from the stages).
This commit is contained in:
Michael Vogt 2023-11-22 13:08:04 +01:00 committed by Ondřej Budai
parent fd61bcdcab
commit 83e66839bc
3 changed files with 72 additions and 19 deletions

View file

@ -311,19 +311,15 @@ class JSONSeqMonitor(BaseMonitor):
self._progress = Progress("pipelines", len(manifest.pipelines))
self._context = Context(origin="org.osbuild")
# result is for modules
def result(self, result: osbuild.pipeline.BuildResult):
# TODO: check pipeline id?
if self._progress.sub_progress:
self._progress.sub_progress.incr()
def begin(self, pipeline: osbuild.Pipeline):
self._context.set_pipeline(pipeline)
self._progress.sub_progress = Progress("stages", len(pipeline.stages))
self.log(f"Starting pipeline {pipeline.name}", origin="org.osbuild.main")
# finish is for pipelines
def finish(self, result: dict):
def finish(self, results: dict):
self._progress.incr()
self.log(f"Finished pipeline {results['name']}", origin="org.osbuild.main")
def stage(self, stage: osbuild.Stage):
self._module(stage)
@ -333,6 +329,14 @@ class JSONSeqMonitor(BaseMonitor):
def _module(self, module: osbuild.Stage):
self._context.set_stage(module)
self.log(f"Starting module {module.name}", origin="org.osbuild.main")
# result is for modules
def result(self, results: osbuild.pipeline.BuildResult):
# TODO: check pipeline id?
if self._progress.sub_progress:
self._progress.sub_progress.incr()
self.log(f"Finished module {results.name}", origin="org.osbuild.main")
def log(self, message, origin: Optional[str] = None):
entry = log_entry(message, self._context.with_origin(origin), self._progress)