|
40 | 40 | # But, if you want to do that you are likely better off |
41 | 41 | # using a filter not associated with an AnnotatedLogger |
42 | 42 | # like the `logging_config.logger_filter_parens` below |
43 | | - "annotations": {"decorated": False}, |
| 43 | + "annotations": {"config_based_filter": True}, |
44 | 44 | }, |
45 | 45 | "logging_config.logger_filter_parens": { |
46 | 46 | "()": AnnotatedFilter, |
47 | | - "annotations": {"decorated": False}, |
| 47 | + "annotations": {"decorated": False, "class_based_filter": True}, |
48 | 48 | "class_annotations": {}, |
49 | 49 | "runtime_annotations": {"custom_runtime": lambda _record: True}, |
50 | 50 | "plugins": [BasePlugin()], |
|
80 | 80 | "formatters": { |
81 | 81 | "logging_config.annotated_formatter": { |
82 | 82 | "class": "pythonjsonlogger.jsonlogger.JsonFormatter", |
83 | | - # Note that this format string uses `time` and `level` which are |
84 | | - # set by the renamer plugin. Because the handler is using the |
85 | | - # annotated_filter the plugings will be run and the fields will be renamed |
86 | | - # This also pulls the `runtime` annotation to a specific place in the log |
| 83 | + # Note that this format string uses `time` which is set by the renamer |
| 84 | + # plugin. It also has `lvl` which is there strictly to test our fallback |
| 85 | + # to using `levelno` in the mocks to determine level. |
87 | 86 | "format": "{time} {lvl} {name} {runtime} {message}", |
88 | 87 | "style": "{", |
89 | 88 | }, |
|
92 | 91 | "style": "{", |
93 | 92 | }, |
94 | 93 | "logging_config.long_formatter": { |
95 | | - "format": "{level} Long message, may be split {message}", |
| 94 | + "format": "{lvl} Long message, may be split {message}", |
96 | 95 | # 3.12 added support for defaults in dict configs |
97 | 96 | # With that we can add the format and defaults below |
98 | 97 | # for a more realistic example. Not all of the messages |
@@ -143,7 +142,7 @@ def runtime(_record: logging.LogRecord) -> str: |
143 | 142 | annotated_logger = AnnotatedLogger( |
144 | 143 | annotations={"hostname": "my-host"}, |
145 | 144 | runtime_annotations={"runtime": runtime}, |
146 | | - plugins=[RenamerPlugin(time="created", level="levelname")], |
| 145 | + plugins=[RenamerPlugin(time="created", lvl="levelname")], |
147 | 146 | log_level=logging.DEBUG, |
148 | 147 | max_length=200, |
149 | 148 | name="annotated_logger.logging_config", |
|
0 commit comments