Skip to content

Commit ea36fbb

Browse files
committed
Split out the JSON renderer from the Cloud Logging formatter
This separates the concern a bit more and allow to configure specific JSON renderer when there's a need to.
1 parent 576d969 commit ea36fbb

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

structlog_gcp/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from structlog.typing import Processor
2+
from structlog.processors import JSONRenderer
23

34
from . import errors, processors
45

@@ -16,5 +17,6 @@ def build_processors(
1617
procs.extend(errors.ReportError(["CRITICAL"]).setup())
1718
procs.extend(errors.ServiceContext(service, version).setup())
1819
procs.extend(processors.FormatAsCloudLogging().setup())
20+
procs.append(JSONRenderer())
1921

2022
return procs

structlog_gcp/processors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class FormatAsCloudLogging:
4444
"""
4545

4646
def setup(self) -> list[Processor]:
47-
return [self, structlog.processors.JSONRenderer()]
47+
return [self]
4848

4949
def __call__(
5050
self, logger: WrappedLogger, method_name: str, event_dict: EventDict

0 commit comments

Comments
 (0)