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? |
Thanks for your contribution, I’ve added a few wishes. Additionally:
thanks again! |
@@ -187,6 +187,8 @@ API Reference | |||
|
|||
.. autofunction:: filter_by_level | |||
|
|||
.. autofunction:: add_log_level_number |
hynek
Feb 5, 2018
Owner
I think this should go under add_log_level since that is still the main one.
I think this should go under add_log_level since that is still the main one.
@@ -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`: |
hynek
Feb 5, 2018
Owner
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.
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.
@@ -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. |
hynek
Feb 5, 2018
Owner
Kind of as above: it should broadly explain what that is, maybe even link to the docs.
Also: Add
not Adds
please.
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