Skip to content

Commit d183d62

Browse files
committed
Cleanup and removing some support for older configurations
1 parent a2f4d6a commit d183d62

File tree

8 files changed

+11
-49
lines changed

8 files changed

+11
-49
lines changed

.github/workflows/pytest.yaml

+2-10
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,8 @@ jobs:
1414
runs-on: ${{ matrix.os }}
1515
strategy:
1616
matrix:
17-
# pytest-forked does not work on windows and we currently use it for isolation
18-
# of logging configs as logging.dictConfig has a setting to not disable old loggers
19-
# but, does seem to trample old handlers, filters and formatters
20-
os: [ubuntu-latest, macos-latest]
21-
python-version: ["3.9", "3.10", "3.11", "3.12", "pypy3.9", "pypy3.10"]
22-
exclude:
23-
- os: macos-latest
24-
python-version: "3.9"
25-
- os: windows-latest
26-
python-version: "3.9"
17+
os: [ubuntu-latest, macos-latest, windows-latest]
18+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
2719

2820
steps:
2921
- uses: actions/checkout@v4

SUPPORT.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This project uses GitHub issues to track bugs and feature requests. Please searc
66

77
For help or questions about using this project, please create an issue or discussion.
88

9-
- Annotated Logger is under active development and maintained by GitHub staff **AND THE COMMUNITY**. We will do our best to respond to support, feature requests, and community questions in a timely manner.
9+
Annotated Logger is under active development and maintained by GitHub staff **AND THE COMMUNITY**. We will do our best to respond to support, feature requests, and community questions in a timely manner.
1010

1111
## GitHub Support Policy
1212

annotated_logger/__init__.py

+1-14
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from makefun import wraps
2525

2626
from annotated_logger.filter import AnnotatedFilter
27-
from annotated_logger.plugins import BasePlugin, RuntimeAnnotationsPlugin
27+
from annotated_logger.plugins import BasePlugin
2828

2929
if TYPE_CHECKING: # pragma: no cover
3030
from collections.abc import MutableMapping
@@ -255,8 +255,6 @@ class AnnotatedLogger:
255255
Args:
256256
----
257257
annotations: Dictionary of annotations to be added to every log message
258-
runtime_annotations: [Deprecated] Dictionary of method references to be called
259-
when a log message is emitted. Use the `RuntimeAnnotationsPlugin` instead.
260258
plugins: list of plugins to use
261259
262260
Methods:
@@ -271,10 +269,7 @@ class AnnotatedLogger:
271269
def __init__( # noqa: PLR0913
272270
self,
273271
annotations: dict[str, Any] | None = None,
274-
runtime_annotations: dict[str, Callable[[logging.LogRecord], Any]]
275-
| None = None,
276272
plugins: list[BasePlugin] | None = None,
277-
formatter: logging.Formatter | None = None,
278273
max_length: int | None = None,
279274
log_level: int = logging.INFO,
280275
name: str = "annotated_logger",
@@ -285,9 +280,7 @@ def __init__( # noqa: PLR0913
285280
Args:
286281
----
287282
annotations: Dictionary of static annotations - default None
288-
runtime_annotations: Dictionary of dynamic annotations - default None
289283
plugins: List of plugins to be applied - default [BasePlugin]
290-
formatter: Formatter for the handler. If none is provided a JsonFormatter
291284
is created and used - default None
292285
max_length: Integer, maximum length of a message before it's broken into
293286
multiple message and log calls. - default None
@@ -315,12 +308,6 @@ def __init__( # noqa: PLR0913
315308
self.annotations = annotations or {}
316309
self.plugins = [BasePlugin()]
317310
self.plugins.extend(plugins)
318-
# Preserve the `runtime_annotations` param for backwards compat
319-
if runtime_annotations:
320-
self.plugins.append(RuntimeAnnotationsPlugin(runtime_annotations))
321-
if formatter and config:
322-
msg = "Cannot pass both formatter and config."
323-
raise ValueError(msg)
324311

325312
if config is None:
326313
config = deepcopy(DEFAULT_LOGGING_CONFIG)

example/invalid_order.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
from annotated_logger import AnnotatedAdapter, AnnotatedLogger
2-
from annotated_logger.plugins import RemoverPlugin
32

43
# Actions runs in async.io it appears and that inejcts `taskName`
54
# But, locally that's not there, so it messes up the absent all tests
6-
annotated_logger = AnnotatedLogger(plugins=[RemoverPlugin(["taskName"])])
5+
annotated_logger = AnnotatedLogger()
76

87
annotate_logs = annotated_logger.annotate_logs
98

example/logging_config.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,10 @@ def runtime(_record: logging.LogRecord) -> str:
159159
# This param is kept for backwards compatibility and creates a
160160
# RuntimeAnnotationsPlugin instead.
161161
# This is left as an example and to provide test coverage.
162-
runtime_annotations={"runtime": runtime},
163-
plugins=[RenamerPlugin(time="created", lvl="levelname")],
162+
plugins=[
163+
RenamerPlugin(time="created", lvl="levelname"),
164+
RuntimeAnnotationsPlugin({"runtime": runtime}),
165+
],
164166
log_level=logging.DEBUG,
165167
max_length=200,
166168
name="annotated_logger.logging_config",

notes.md

-10
This file was deleted.

test/demo.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22

33
from annotated_logger import AnnotatedLogger
4+
from annotated_logger.plugins import RuntimeAnnotationsPlugin
45

56

67
def runtime(_record: logging.LogRecord):
@@ -9,7 +10,7 @@ def runtime(_record: logging.LogRecord):
910

1011
annotated_logger = AnnotatedLogger(
1112
annotations={"extra": "new data"},
12-
runtime_annotations={"runtime": runtime},
13+
plugins=[RuntimeAnnotationsPlugin({"runtime": runtime})],
1314
)
1415

1516
annotate_logs = annotated_logger.annotate_logs

test/test_decorator.py

-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
import logging
43
from typing import TYPE_CHECKING
54

65
import pytest
@@ -10,7 +9,6 @@
109
import example.calculator
1110
import example.default
1211
import test.demo
13-
from annotated_logger import AnnotatedLogger
1412
from annotated_logger.plugins import RuntimeAnnotationsPlugin
1513

1614
if TYPE_CHECKING:
@@ -620,10 +618,3 @@ def test_annotated_logger_must_be_first(self):
620618
TypeError, match="^annotated_logger must be the first argument$"
621619
):
622620
import example.invalid_order # noqa: F401
623-
624-
def test_cannot_use_both_formatter_and_config(self):
625-
formatter = logging.Formatter("%(time)s %(lvl)s %(name)s %(message)s")
626-
with pytest.raises(
627-
ValueError, match="^Cannot pass both formatter and config.$"
628-
):
629-
AnnotatedLogger(formatter=formatter, config={"logging": "config"})

0 commit comments

Comments
 (0)