Skip to content

Commit

Permalink
Split out the JSON renderer from the Cloud Logging formatter (#30)
Browse files Browse the repository at this point in the history
This separates the concern a bit more and allow to configure specific
JSON renderer when there's a need to.
  • Loading branch information
multani authored Feb 25, 2024
1 parent 576d969 commit 64b0292
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion structlog_gcp/base.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import structlog.processors
from structlog.typing import Processor

from . import errors, processors
Expand All @@ -16,5 +17,5 @@ def build_processors(
procs.extend(errors.ReportError(["CRITICAL"]).setup())
procs.extend(errors.ServiceContext(service, version).setup())
procs.extend(processors.FormatAsCloudLogging().setup())

procs.append(structlog.processors.JSONRenderer())
return procs
2 changes: 1 addition & 1 deletion structlog_gcp/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class FormatAsCloudLogging:
"""

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

def __call__(
self, logger: WrappedLogger, method_name: str, event_dict: EventDict
Expand Down

0 comments on commit 64b0292

Please sign in to comment.