Skip to content

Commit 29371be

Browse files
Add merge_contextvars to default structlog configuration
1 parent 2abeed6 commit 29371be

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Changelog
2+
## v1.9.1 3/11/26
3+
- Add merge_contextvars to default structlog configuration
4+
25
## v1.9.0 3/10/26
36
- Add capability to upload arbitrary file type to S3
47

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "nypl_py_utils"
7-
version = "1.9.0"
7+
version = "1.9.1"
88
authors = [
99
{ name="Aaron Friedman", email="aaronfriedman@nypl.org" },
1010
]

src/nypl_py_utils/functions/log_helper.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,19 @@
1515
# Configure structlog to be machine-readable first and foremost
1616
# while still making it easy for humans to parse
1717
# End result (without additional bindings) is JSON like this:
18-
#
19-
# { "logger": "module param"
20-
# "message": "this is a test log event",
21-
# "level": "info",
22-
# "timestamp": "2023-11-01 18:50:47"}
23-
#
18+
# {
19+
# "logger": "module param",
20+
# "message": "this is a test log event",
21+
# "level": "info",
22+
# "timestamp": "2023-11-01 18:50:47"
23+
# }
2424
def get_structlog(module):
2525
structlog.configure(
2626
processors=[
27+
structlog.contextvars.merge_contextvars,
2728
structlog.processors.add_log_level,
28-
structlog.processors.TimeStamper(fmt="iso"),
29-
structlog.processors.EventRenamer("message"),
29+
structlog.processors.TimeStamper(fmt='iso'),
30+
structlog.processors.EventRenamer('message'),
3031
structlog.processors.JSONRenderer(),
3132
],
3233
context_class=dict,

0 commit comments

Comments
 (0)