22
33import sys
44import time
5- import gzip
65import json
76import lzma
87import atexit
1716from atex .aggregator .json import LZMAJSONAggregator
1817from atex .fmf import FMFTests
1918
20- logger = logging .getLogger ("ATEX" )
21-
2219
2320def kv_pair (keyval ):
2421 if "=" not in keyval :
@@ -42,21 +39,43 @@ def parse_args():
4239 return parser .parse_args ()
4340
4441
42+ class OrchestratorLogFilter (logging .Filter ):
43+ """
44+ Filter (show) only messages from the atex.orchestrator logger,
45+ show all warnings (and above) from everywhere,
46+ show all from the root logger (logging.*).
47+ """
48+ def filter (self , record ):
49+ return (
50+ record .levelno >= logging .WARNING
51+ or record .name .startswith ("atex.orchestrator" )
52+ or record .name == "root"
53+ )
54+
55+
4556def setup_logging ():
4657 """Setup logging configuration with console and file handlers."""
47- # Log brief info to console, but be verbose in a separate file-based log (uploaded as artifact)
58+ # console - keep it brief, just basic orchestration + warnings
4859 console_log = logging .StreamHandler (sys .stderr )
4960 console_log .setLevel (logging .INFO )
61+ console_log .addFilter (OrchestratorLogFilter ())
62+ console_log .setFormatter (logging .Formatter (
63+ fmt = "%(asctime)s: %(message)s" ,
64+ datefmt = "%Y-%m-%d %H:%M:%S" ,
65+ ))
5066
51- debug_log_fobj = gzip .open ("atex_debug.log.gz" , "wt" )
67+ # debug log - store ALL debugging info, compressed
68+ debug_log_fobj = lzma .open ("atex_debug.log.xz" , "wt" )
5269 atexit .register (debug_log_fobj .close )
5370 file_log = logging .StreamHandler (debug_log_fobj )
5471 file_log .setLevel (logging .DEBUG )
72+ file_log .setFormatter (logging .Formatter (
73+ fmt = "%(asctime)s %(name)s: %(message)s" ,
74+ datefmt = "%Y-%m-%d %H:%M:%S" ,
75+ ))
5576
5677 logging .basicConfig (
5778 level = logging .DEBUG ,
58- format = "%(asctime)s %(name)s: %(message)s" ,
59- datefmt = "%Y-%m-%d %H:%M:%S" ,
6079 handlers = (console_log , file_log ),
6180 force = True ,
6281 )
@@ -65,7 +84,7 @@ def setup_logging():
6584def setup_signal_handlers ():
6685 """Setup signal handlers for graceful abort."""
6786 def abort_on_signal (signum , _ ):
68- logger .error (f"got signal { signum } , aborting" )
87+ logging .error (f"got signal { signum } , aborting" )
6988 raise SystemExit (1 )
7089
7190 signal .signal (signal .SIGTERM , abort_on_signal )
@@ -97,13 +116,13 @@ def main():
97116 },
98117 )
99118
100- logger .info (f"plan: { args .plan } " )
101- logger .info (f"os major version: { args .os_major_version } " )
102- logger .info (f"arch: { args .arch } " )
103- logger .info (f"compose: { args .compose } " )
104- logger .info ("will run:" )
119+ logging .info (f"plan: { args .plan } " )
120+ logging .info (f"os major version: { args .os_major_version } " )
121+ logging .info (f"arch: { args .arch } " )
122+ logging .info (f"compose: { args .compose } " )
123+ logging .info ("will run:" )
105124 for test in fmf_tests .tests :
106- logger .info (f" { test } " )
125+ logging .info (f" { test } " )
107126
108127 # Setup result aggregator
109128 output_results = f"results-centos-stream-{ args .os_major_version } -{ args .arch } .json.xz"
@@ -140,30 +159,31 @@ def main():
140159 )
141160 stack .enter_context (orchestrator )
142161
143- logger .info ("Starting test execution..." )
162+ logging .info ("Starting test execution..." )
144163 next_writeout = time .monotonic () + 600
145164 while orchestrator .serve_once ():
146165 if time .monotonic () > next_writeout :
147- logger .info (
166+ logging .info (
167+ "STATISTICS: "
148168 f"queued: { len (orchestrator .to_run )} /{ len (fmf_tests .tests )} tests, "
149169 f"running: { len (orchestrator .running_tests )} tests" ,
150170 )
151171 next_writeout = time .monotonic () + 600
152172 time .sleep (1 )
153173
154- logger .info ("Test execution completed!" )
174+ logging .info ("Test execution completed!" )
155175
156176 # Log final output locations
157- logger .info (f"Results written to: { output_results } " )
158- logger .info (f"Test files in: { output_files } " )
177+ logging .info (f"Results written to: { output_results } " )
178+ logging .info (f"Test files in: { output_files } " )
159179
160180 # Read back the compressed JSON results and exit with non-0 if anything failed
161181 with lzma .open (output_results , "rt" ) as results :
162182 for line in results :
163183 fields = json .loads (line )
164184 # [platform, status, test name, subtest name, files, note]
165185 if fields [1 ] in ("fail" , "error" , "infra" ):
166- logger . warning ("failures found in the results, exiting with 1" )
186+ logging . error ("failures found in the results, exiting with 1" )
167187 sys .exit (1 )
168188
169189
0 commit comments