Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff29e05322 |
@@ -13,7 +13,7 @@ and emit; their records flow into the handlers `log_setup` wired.
|
||||
## Install
|
||||
|
||||
```
|
||||
log_setup @ git+ssh://git@git.rethinkstudios.io/rethink-public/log_setup.git@v0.3.0
|
||||
log_setup @ git+ssh://git@git.rethinkstudios.io/rethink-public/log_setup.git@v0.3.1
|
||||
```
|
||||
|
||||
No dependencies — stdlib only.
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "log_setup"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
description = "stdlib app-entry-point logging setup: live run.log, rotation, gzip, retention, consistent format"
|
||||
requires-python = ">=3.10"
|
||||
dependencies = []
|
||||
|
||||
@@ -19,4 +19,4 @@ from .setup import setup_logging
|
||||
|
||||
__all__ = ["setup_logging"]
|
||||
|
||||
__version__ = "0.3.0"
|
||||
__version__ = "0.3.1"
|
||||
|
||||
@@ -15,6 +15,11 @@ DEFAULT_FORMAT = "%(asctime)s | %(name)s | %(levelname)s | %(message)s"
|
||||
DEFAULT_DATEFMT = "%Y-%m-%d %H:%M:%S"
|
||||
|
||||
_RESERVED = frozenset(vars(logging.makeLogRecord({})).keys()) | {"message", "asctime"}
|
||||
# this formatter's own canonical output keys — stdlib's LogRecord rejects `extra` keys
|
||||
# colliding with real attribute names (e.g. `module`), but `time`/`level` are NOT
|
||||
# LogRecord attrs, so a caller's extra={"time":...}/{"level":...} would otherwise
|
||||
# overwrite the UTC timestamp / levelname. guard them explicitly
|
||||
_OUTPUT_KEYS = frozenset({"time", "level", "module", "message"})
|
||||
|
||||
|
||||
class JsonLinesFormatter(logging.Formatter):
|
||||
@@ -38,7 +43,7 @@ class JsonLinesFormatter(logging.Formatter):
|
||||
"message": record.getMessage(),
|
||||
}
|
||||
for key, value in record.__dict__.items():
|
||||
if key not in _RESERVED and not key.startswith("_"):
|
||||
if key not in _RESERVED and key not in _OUTPUT_KEYS and not key.startswith("_"):
|
||||
payload[key] = value
|
||||
if record.exc_info:
|
||||
payload["exc_info"] = self.formatException(record.exc_info)
|
||||
|
||||
Reference in New Issue
Block a user