Skip to content

Commit 16754ed

Browse files
authored
Drop unmaintained logmatic (#18)
1 parent 3de9f08 commit 16754ed

File tree

4 files changed

+54
-8
lines changed

4 files changed

+54
-8
lines changed

.circleci/config.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ jobs:
2929
root: .
3030
paths:
3131
- ./coverage_*.xml
32+
test-py313:
33+
<<: *test-py38
34+
docker:
35+
- image: cimg/python:3.13
3236
test-py312:
3337
<<: *test-py38
3438
docker:
@@ -57,7 +61,7 @@ jobs:
5761
command: |
5862
curl -Os https://uploader.codecov.io/latest/linux/codecov
5963
chmod +x codecov
60-
for py in 3.8 3.9 3.10 3.11 3.12; do
64+
for py in 3.8 3.9 3.10 3.11 3.12 3.13; do
6165
./codecov \
6266
--nonZero \
6367
--token $CODECOV_TOKEN_RECONPLOGGER \
@@ -97,6 +101,8 @@ workflows:
97101
only: /^v\d+\.\d+\.\d+.*$/
98102
- test-py38:
99103
<<: *buildreq
104+
- test-py313:
105+
<<: *buildreq
100106
- test-py312:
101107
<<: *buildreq
102108
- test-py311:
@@ -107,6 +113,7 @@ workflows:
107113
<<: *buildreq
108114
- codecov:
109115
requires:
116+
- test-py313
110117
- test-py312
111118
- test-py311
112119
- test-py310

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ repos:
1515
exclude: .bumpversion.cfg
1616

1717
- repo: https://github.com/psf/black
18-
rev: 23.12.1
18+
rev: 24.10.0
1919
hooks:
2020
- id: black
2121

2222
- repo: https://github.com/astral-sh/ruff-pre-commit
23-
rev: v0.1.13
23+
rev: v0.8.4
2424
hooks:
2525
- id: ruff
2626
args: ["--fix"]

reconplogger.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import datetime
12
import os
23
import yaml
34
import logging
45
import logging.config
6+
import pythonjsonlogger
57
from contextlib import contextmanager
68
from contextvars import ContextVar
79
from importlib.util import find_spec
@@ -47,7 +49,7 @@ def _request_patch(slf, *args, **kwargs):
4749
},
4850
"json": {
4951
"format": reconplogger_format.replace("asctime", "timestamp"),
50-
"class": "logmatic.JsonFormatter",
52+
"class": "reconplogger.JsonFormatter",
5153
},
5254
},
5355
"handlers": {
@@ -496,3 +498,39 @@ def rlogger(self, logger: Optional[Union[bool, logging.Logger]]):
496498
self._rlogger = logger_setup()
497499
else:
498500
self._rlogger = logger
501+
502+
503+
class JsonFormatter(pythonjsonlogger.json.JsonFormatter):
504+
"""JSON formatter from https://github.com/logmatic/logmatic-python/
505+
506+
The MIT License (MIT)
507+
Copyright (c) 2017 Logmatic.io
508+
"""
509+
510+
def __init__(
511+
self,
512+
fmt="%(asctime) %(name) %(processName) %(filename) %(funcName) %(levelname) %(lineno) %(module) %(threadName) %(message)",
513+
datefmt="%Y-%m-%dT%H:%M:%SZ%z",
514+
style="%",
515+
extra={},
516+
*args,
517+
**kwargs,
518+
):
519+
self._extra = extra
520+
pythonjsonlogger.json.JsonFormatter.__init__(
521+
self, fmt=fmt, datefmt=datefmt, *args, **kwargs
522+
)
523+
524+
def process_log_record(self, log_record):
525+
# Enforce the presence of a timestamp
526+
if "asctime" in log_record:
527+
log_record["timestamp"] = log_record["asctime"]
528+
else:
529+
log_record["timestamp"] = datetime.datetime.now(
530+
datetime.timezone.utc
531+
).strftime("%Y-%m-%dT%H:%M:%S.%fZ%z")
532+
533+
if self._extra is not None:
534+
for key, value in self._extra.items():
535+
log_record[key] = value
536+
return super().process_log_record(log_record)

setup.cfg

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ py_modules =
55
test_suite = reconplogger_tests
66
python_requires = >=3.8
77
install_requires =
8-
logmatic-python>=0.1.7
8+
python-json-logger>=3.2.1
99
PyYAML>=3.13
1010

1111

@@ -56,11 +56,12 @@ classifiers =
5656
Programming Language :: Python
5757
Programming Language :: Python :: 3
5858
Programming Language :: Python :: 3 :: Only
59-
Programming Language :: Python :: 3.6
60-
Programming Language :: Python :: 3.7
6159
Programming Language :: Python :: 3.8
6260
Programming Language :: Python :: 3.9
6361
Programming Language :: Python :: 3.10
62+
Programming Language :: Python :: 3.11
63+
Programming Language :: Python :: 3.12
64+
Programming Language :: Python :: 3.13
6465
Intended Audience :: Developers
6566
License :: OSI Approved :: MIT License
6667
Operating System :: POSIX :: Linux
@@ -76,7 +77,7 @@ build_dir = sphinx/_build
7677

7778

7879
[tox:tox]
79-
envlist = py{38,39,310,311,312},no-extras
80+
envlist = py{38,39,310,311,312,313},no-extras
8081

8182

8283
[testenv]

0 commit comments

Comments
 (0)