Skip to content

Add MregCliLogger tests and fix logging configuration#423

Merged
pederhan merged 7 commits into
masterfrom
expand-tests-19112025
May 22, 2026
Merged

Add MregCliLogger tests and fix logging configuration#423
pederhan merged 7 commits into
masterfrom
expand-tests-19112025

Conversation

@pederhan

@pederhan pederhan commented Nov 20, 2025

Copy link
Copy Markdown
Member

Adds some basic tests to ensure MregCliLogger behaves like we expect it to.

Forced logging reconfiguration

This PR also modifies MregCliLogger.start_logging() to use logging.basicConfig(..., force=true) to ensure the logger always re-runs basicConfig if called multiple times. This fixes a bug discovered by these tests, which caused the logger to not switch log files when a different log file path was passed in. This affected logging start when using the -filename option.

Docs for logging.basicConfig stating this behavior

Bug in action:

user@example.com> logging status
INFO > /tmp/mreg-cli.a3fp2t0p.360443/mreg-cli.log (7 lines, 857.0B)
user@example.com> logging start -filename /tmp/mreg-cli.a3fp2t0p.360443/mreg-cli.log.2
Logging started: INFO > /tmp/mreg-cli.a3fp2t0p.360443/mreg-cli.log.2
user@example.com> logging status
ERROR: Unable to read log file /tmp/mreg-cli.a3fp2t0p.360443/mreg-cli.log.2: [Errno 2] No such file or directory: '/tmp/mreg-cli.a3fp2t0p.360443/mreg-cli.log.2'

Since logging was already configured, logging.basicConfig silently skipped configuration, and thus did not create the new log file /tmp/mreg-cli.a3fp2t0p.360443/mreg-cli.log.2, causing an error when logging status attempts to read it.

@pederhan pederhan changed the title Add MregCliLogger tests Add MregCliLogger tests and fix logging configuration Dec 8, 2025
@pederhan pederhan requested a review from terjekv December 9, 2025 08:36
@pederhan pederhan merged commit 4974b28 into master May 22, 2026
18 checks passed
@pederhan pederhan deleted the expand-tests-19112025 branch May 22, 2026 09:11
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.

1 participant