From 87015318d3e060bf356288b4055d2b7f52c92eef Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 4 Mar 2024 12:57:44 +0100 Subject: [PATCH] osbuild: tweak "origin=" values, thanks to Simon! --- osbuild/buildroot.py | 2 +- osbuild/main_cli.py | 6 +++--- osbuild/monitor.py | 8 ++++---- test/mod/test_monitor.py | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/osbuild/buildroot.py b/osbuild/buildroot.py index 6b3475a8..1ceb06be 100644 --- a/osbuild/buildroot.py +++ b/osbuild/buildroot.py @@ -337,7 +337,7 @@ class BuildRoot(contextlib.AbstractContextManager): poller = select.poll() poller.register(proc.stdout.fileno(), READ_ONLY) - stage_origin = "stages/" + stage_name + stage_origin = os.path.join("stages", stage_name) while True: buf = self.read_with_timeout(proc, poller, start, timeout) if not buf: diff --git a/osbuild/main_cli.py b/osbuild/main_cli.py index 21e38b9f..570e7a0c 100644 --- a/osbuild/main_cli.py +++ b/osbuild/main_cli.py @@ -164,7 +164,7 @@ def osbuild_cli() -> int: if not monitor_name: monitor_name = "NullMonitor" if args.json else "LogMonitor" monitor = osbuild.monitor.make(monitor_name, args.monitor_fd, manifest) - monitor.log(f"starting {args.manifest_path}", origin="org.osbuild.main") + monitor.log(f"starting {args.manifest_path}", origin="osbuild.main_cli") try: with ObjectStore(args.store) as object_store: @@ -187,10 +187,10 @@ def osbuild_cli() -> int: stage_timeout=stage_timeout ) if r["success"]: - monitor.log(f"manifest {args.manifest_path} finished successfully", origin="org.osbuild.main") + monitor.log(f"manifest {args.manifest_path} finished successfully", origin="osbuild.main_cli") else: # if we had monitor.error() we could use that here - monitor.log(f"manifest {args.manifest_path} failed", origin="org.osbuild.main") + monitor.log(f"manifest {args.manifest_path} failed", origin="osbuild.main_cli") if r["success"] and exports: for pid in exports: diff --git a/osbuild/monitor.py b/osbuild/monitor.py index 80b4275a..9638f739 100644 --- a/osbuild/monitor.py +++ b/osbuild/monitor.py @@ -316,12 +316,12 @@ class JSONSeqMonitor(BaseMonitor): self._context.set_pipeline(pipeline) if pipeline.stages: self._progress.sub_progress = Progress("stages", len(pipeline.stages)) - self.log(f"Starting pipeline {pipeline.name}", origin="org.osbuild.main") + self.log(f"Starting pipeline {pipeline.name}", origin="osbuild.monitor") # finish is for pipelines def finish(self, results: dict): self._progress.incr() - self.log(f"Finished pipeline {results['name']}", origin="org.osbuild.main") + self.log(f"Finished pipeline {results['name']}", origin="osbuild.monitor") def stage(self, stage: osbuild.Stage): self._module(stage) @@ -331,14 +331,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") + self.log(f"Starting module {module.name}", origin="osbuild.monitor") # result is for modules def result(self, result: osbuild.pipeline.BuildResult): # we may need to check pipeline ids here in the future if self._progress.sub_progress: self._progress.sub_progress.incr() - self.log(f"Finished module {result.name}", origin="org.osbuild.main") + self.log(f"Finished module {result.name}", origin="osbuild.monitor") def log(self, message, origin: Optional[str] = None): entry = log_entry(message, self._context.with_origin(origin), self._progress) diff --git a/test/mod/test_monitor.py b/test/mod/test_monitor.py index d152a68e..5126bbcb 100644 --- a/test/mod/test_monitor.py +++ b/test/mod/test_monitor.py @@ -246,7 +246,7 @@ def test_json_progress_monitor(): logitem = json.loads(log[i]) assert logitem["message"] == "Starting module org.osbuild.noop" - assert logitem["context"]["origin"] == "org.osbuild.main" + assert logitem["context"]["origin"] == "osbuild.monitor" assert logitem["context"]["pipeline"]["name"] == "test-pipeline-first" assert logitem["context"]["pipeline"]["stage"]["name"] == "org.osbuild.noop" id_start_module = logitem["context"]["id"] @@ -277,7 +277,7 @@ def test_json_progress_monitor(): logitem = json.loads(log[i]) assert logitem["message"] == "Starting pipeline test-pipeline-second" - assert logitem["context"]["origin"] == "org.osbuild.main" + assert logitem["context"]["origin"] == "osbuild.monitor" assert logitem["context"]["pipeline"]["name"] == "test-pipeline-second" i += 1