Skip to content

Commit

Permalink
add logging stream name to test logs
Browse files Browse the repository at this point in the history
In avocado-framework#5665 we introduced the logging stream name in test logs, this added
more possibilities for user how to post-process test logs.
Unfortunately, this change also hided information about modules where
the log has been created. This issue has been solved in avocado-framework#5732.
This commit connects those two solutions by storing stream and module
names.

Referencei: avocado-framework#5665 avocado-framework#5732
Signed-off-by: Jan Richter <[email protected]>
  • Loading branch information
richtja committed Dec 8, 2023
1 parent 5d68392 commit 5db5a68
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions avocado/core/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,7 @@ def __exit__(self, _exc_type, _exc_value, _traceback):
def __start_job_logging(self):
# Enable test logger
full_log = os.path.join(self.logdir, "full.log")
fmt = (
"%(asctime)s %(module)-16.16s L%(lineno)-.4d %(levelname)-5.5s| %(message)s"
)
fmt = "%(asctime)s %(name)s %(module)-16.16s L%(lineno)-.4d %(levelname)-5.5s| %(message)s"
output.add_log_handler(
LOG_JOB,
logging.FileHandler,
Expand Down
2 changes: 1 addition & 1 deletion avocado/core/utils/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def start_logging(config, queue):
log_handler = RunnerLogHandler(queue, "log")
stdout_handler = RunnerLogHandler(queue, "stdout")
stderr_handler = RunnerLogHandler(queue, "stderr")
fmt = "%(asctime)s %(module)-16.16s L%(lineno)-.4d %(levelname)-5.5s| %(message)s"
fmt = "%(asctime)s %(name)s %(module)-16.16s L%(lineno)-.4d %(levelname)-5.5s| %(message)s"
formatter = logging.Formatter(fmt=fmt)
log_handler.setFormatter(formatter)
stdout_handler.setFormatter(formatter)
Expand Down
2 changes: 1 addition & 1 deletion selftests/functional/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ def check_matplotlib_logs(file_path):
self.assertTrue(os.path.exists(file_path))
with open(file_path, encoding="utf-8") as file:
stream = file.read()
self.assertIn("matplotlib DEBUG|", stream)
self.assertIn("matplotlib __init__ L0337 DEBUG|", stream)

log_dir = os.path.join(self.tmpdir.name, "latest")
test_log_dir = os.path.join(
Expand Down

0 comments on commit 5db5a68

Please sign in to comment.