Skip to content

Commit 74814bc

Browse files
committed
Working on smushing mutations
1 parent a3fcf2b commit 74814bc

4 files changed

Lines changed: 8 additions & 5 deletions

File tree

annotated_logger/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class AnnotatedClass(Protocol[C_co]):
8787
Annotations = dict[str, Any]
8888

8989

90-
DEFAULT_LOGGING_CONFIG = {
90+
DEFAULT_LOGGING_CONFIG = { # pragma: no mutate
9191
"version": 1,
9292
"disable_existing_loggers": False,
9393
"filters": {
@@ -337,6 +337,7 @@ def __init__( # noqa: PLR0913
337337
log_level: int = logging.INFO,
338338
name: str = "annotated_logger",
339339
config: dict[str, Any] | Literal[False] | None = None,
340+
# TODO: boolean for correlation_id and then auto generate it
340341
) -> None:
341342
"""Store the settings.
342343

example/logging_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
# But, if you want to do that you are likely better off
4141
# using a filter not associated with an AnnotatedLogger
4242
# like the `logging_config.logger_filter_parens` below
43-
# "annotations": {"decorated": False}, # noqa: ERA001
43+
"annotations": {"decorated": False},
4444
},
4545
"logging_config.logger_filter_parens": {
4646
"()": AnnotatedFilter,
@@ -84,7 +84,7 @@
8484
# set by the renamer plugin. Because the handler is using the
8585
# annotated_filter the plugings will be run and the fields will be renamed
8686
# This also pulls the `runtime` annotation to a specific place in the log
87-
"format": "{time} {level} {name} {runtime} {message}",
87+
"format": "{time} {lvl} {name} {runtime} {message}",
8888
"style": "{",
8989
},
9090
"logging_config.error_formatter": {

test/test_decorator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,5 +601,7 @@ def test_annotated_logger_must_be_first(self):
601601

602602
def test_cannot_use_both_formatter_and_config(self):
603603
formatter = logging.Formatter("%(time)s %(lvl)s %(name)s %(message)s")
604-
with pytest.raises(ValueError, match="Cannot pass both formatter and config."):
604+
with pytest.raises(
605+
ValueError, match="^Cannot pass both formatter and config.$"
606+
):
605607
AnnotatedLogger(formatter=formatter, config={"logging": "config"})

test/test_logging_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_base_logging(self, annotated_logger_mock):
2222
annotated_logger_mock.assert_logged(
2323
level,
2424
f"this is {level}",
25-
present={"hostname": "my-host"},
25+
present={"decorated": False},
2626
absent=["weird"],
2727
)
2828

0 commit comments

Comments
 (0)