Skip to content

Add new log level: TRACE (5)#1927

Open
hmpf wants to merge 7 commits into
mainfrom
add-log-level-trace
Open

Add new log level: TRACE (5)#1927
hmpf wants to merge 7 commits into
mainfrom
add-log-level-trace

Conversation

@hmpf
Copy link
Copy Markdown
Contributor

@hmpf hmpf commented May 7, 2026

Scope and purpose

In order to be able to filter logs better in production I want to add an additional log level, for debugging at an even higher level of detail.

Contributor Checklist

Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to Argus can be found in the
Development docs.

  • Added a changelog fragment for towncrier
  • Added/amended tests for new/changed code
  • Added/changed documentation, including updates to the user manual if feature flow or UI is considerably changed
  • Linted/formatted the code with ruff and djLint, easiest by using pre-commit
  • The first line of the commit message continues the sentence "If applied, this commit will ...", starts with a capital letter, does not end with punctuation and is 50 characters or less long. See our how-to
  • If applicable: Created new issues if this PR does not fix the issue completely/there is further work to be done
  • If this results in changes in the UI: Added screenshots of the before and after
  • If this results in changes to the database model: Updated the ER diagram

@hmpf hmpf requested a review from a team May 7, 2026 10:49
@hmpf hmpf self-assigned this May 7, 2026
@hmpf hmpf added the logging label May 7, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Warning

1 of 1 new test names are missing convention keywords (given/when/then/it_should)

File Test name
tests/test_logging_utils.py test_logging_with_level_TRACE_should_not_trigger_any_errors
Why am I seeing this?

Test names should follow a loose given/when/then pattern with keywords like given, when, then, or it_should. This is a suggestion, not a blocker. The check runs on new test methods added in this PR.

Examples:

  • test_when_no_incidents_then_returns_empty_list
  • test_it_should_create_incident_with_set_description
  • test_given_expired_token_when_refreshing_then_raises_error

@hmpf hmpf force-pushed the add-log-level-trace branch from afc0408 to 96b0748 Compare May 7, 2026 10:53
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Test results

    8 files  1 720 suites   2m 57s ⏱️
  934 tests   933 ✅ 1 💤 0 ❌
7 472 runs  7 464 ✅ 8 💤 0 ❌

Results for commit 469c044.

♻️ This comment has been updated with latest results.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

❌ Patch coverage is 78.37838% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.53%. Comparing base (7c04efb) to head (469c044).

Files with missing lines Patch % Lines
src/argus/logging/utils.py 63.63% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1927      +/-   ##
==========================================
- Coverage   88.60%   88.53%   -0.08%     
==========================================
  Files         146      147       +1     
  Lines        7093     7115      +22     
==========================================
+ Hits         6285     6299      +14     
- Misses        808      816       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hmpf
Copy link
Copy Markdown
Contributor Author

hmpf commented May 7, 2026

This should probably be documented somewhere, but I'm not sure where. It is an addition/alteration to standard python.

Copy link
Copy Markdown
Contributor

@aleksfl aleksfl left a comment

Choose a reason for hiding this comment

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

Seems to works as it should, and looks alright. Some comments on things that looked apparent.

Comment thread src/argus/logging/utils.py Outdated
setattr(logging.Logger, level_name.lower(), log_with_custom_level)


_add_logging_level("TRACE", 5)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does it not make more sense to use the setup_logging method for consistency?

Copy link
Copy Markdown
Contributor Author

@hmpf hmpf May 7, 2026

Choose a reason for hiding this comment

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

It's an ugly hack so that readthedocs builds.

Doing it like this makes it impossible to test without this function having been run. Using setup_logging won't change that.

Comment thread src/argus/site/settings/__init__.py
@hmpf hmpf requested a review from aleksfl May 7, 2026 11:40
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 7, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
E Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copy link
Copy Markdown
Contributor

@aleksfl aleksfl left a comment

Choose a reason for hiding this comment

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

Did some final testing, my comments were addressed. All good.

@hmpf hmpf requested a review from a team May 7, 2026 12:55
@hmpf hmpf mentioned this pull request May 7, 2026
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants