-
-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add log level numbers #151
Conversation
Looks like style failures are from changes I haven't made. Would you prefer they be fixed in this PR or separately and then this branch merged/rebased? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution, I’ve added a few wishes.
Additionally:
- it needs a changelog entry.
- it would be nice if you could use double quotes
"
-only in new code - yes, it would be nice if you could fix the style issues too, so I don’t have to fix and rebase your PR
thanks again!
docs/api.rst
Outdated
@@ -187,6 +187,8 @@ API Reference | |||
|
|||
.. autofunction:: filter_by_level | |||
|
|||
.. autofunction:: add_log_level_number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should go under add_log_level since that is still the main one.
docs/standard-library.rst
Outdated
@@ -58,6 +58,9 @@ Processors | |||
:func:`~structlog.stdlib.add_logger_name`: | |||
Adds the name of the logger to the event dictionary under the key ``logger``. | |||
|
|||
:func:`~structlog.stdlib.add_log_level_number`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, maybe explain a bit more what a log level number is? Someone reading this who doesn’t know what a log level number is, will have not clue what this is support to be.
src/structlog/stdlib.py
Outdated
@@ -330,6 +330,14 @@ def filter_by_level(logger, name, event_dict): | |||
raise DropEvent | |||
|
|||
|
|||
def add_log_level_number(logger, method_name, event_dict): | |||
""" | |||
Adds the log level number to the event dict. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of as above: it should broadly explain what that is, maybe even link to the docs.
Also: Add
not Adds
please.
Codecov Report
@@ Coverage Diff @@
## master #151 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 13 13
Lines 810 813 +3
Branches 105 105
=====================================
+ Hits 810 813 +3
Continue to review full report at Codecov.
|
Doesn't work. Doesn't like `:meth:` This reverts commit 2cb8bcb.
@hynek Take another look? I believe I've addressed issues |
Thanks! |
When combing through logs, I find it's sometimes helpful to filter by a range of log levels. Currently this must be done by checking log level strings. This adds the number so it's easier to do such a check:
With only log levels:
log_level in ("error", "warning", "critical")
With log level numbers:
log_level_number >= 30