Skip to content

[CLI] Make per-run log files unique by appending timestamp + open with mode="w" (fixes #984)#83

Merged
oxesoft merged 1 commit into
project-chip:v2.15-cli-developfrom
abhisheksingh-esp:fix/984_unique_log_file_per_run
May 20, 2026
Merged

[CLI] Make per-run log files unique by appending timestamp + open with mode="w" (fixes #984)#83
oxesoft merged 1 commit into
project-chip:v2.15-cli-developfrom
abhisheksingh-esp:fix/984_unique_log_file_per_run

Conversation

@abhisheksingh-esp
Copy link
Copy Markdown

Fixes #984.

Root cause: configure_logger_for_run in
certification-tool-cli/th_cli/test_run/logging.py derived the log file path
solely from --title (test_run_{title}.log) and loguru.logger.add(...)
defaults to append mode. Reusing -n NAME across runs caused successive runs
to be concatenated into the same file.
Change:

  • Append a timestamp suffix (_YYYY-MM-DD-HH-MM-SS) to the log filename inside
    configure_logger_for_run, so every run produces a unique file regardless
    of the -n NAME value (matches the convention suggested by @OlivierGre).
  • Pass mode="w" to logger.add(...) as defense-in-depth, in case two runs
    ever land on the exact same path (e.g. same second).
    No public API change; configure_logger_for_run(title) still returns the
    resolved path used by run_tests at the end of execution.
    Verification:
  • Run the same test twice with -n my_run. Two distinct files in run_logs/,
    each containing only its own run.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 14, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the logging configuration to include a timestamp in log filenames and sets the file mode to write. A review comment identifies a potential portability issue on Windows systems where the 'title' parameter might contain invalid characters like colons, and provides a code suggestion to sanitize the string.

Comment thread th_cli/test_run/logging.py Outdated
@abhisheksingh-esp abhisheksingh-esp force-pushed the fix/984_unique_log_file_per_run branch from 519ae4a to 8d92cd1 Compare May 14, 2026 10:14
@rquidute rquidute self-requested a review May 14, 2026 11:15
Copy link
Copy Markdown
Contributor

@antonio-amjr antonio-amjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @abhisheksingh-esp,

Seems good, but I would like to ask for a little change if I may.
Let me know what you think of the suggestion below.

Comment thread th_cli/test_run/logging.py Outdated
@abhisheksingh-esp abhisheksingh-esp force-pushed the fix/984_unique_log_file_per_run branch from 13a30a5 to 2ad05bf Compare May 20, 2026 09:50
@oxesoft oxesoft merged commit 350d71b into project-chip:v2.15-cli-develop May 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants