Skip to content

Commit

Permalink
fix logging format config
Browse files Browse the repository at this point in the history
  • Loading branch information
livioribeiro committed May 9, 2024
1 parent 09d51bf commit 8d62d60
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/selva/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ def setup(settings: Settings):
logger_factory=structlog.stdlib.LoggerFactory(),
)

log_format = settings.logging.get("log_format")
log_format = settings.logging.get("format")
if not log_format:
log_format = "console" if sys.stderr.isatty() else "json"

if log_format == "json":
renderer = structlog.processors.JSONRenderer()
elif log_format == "logfmt":
renderer = structlog.processors.LogfmtRenderer()
renderer = structlog.processors.LogfmtRenderer(bool_as_flag=False)
elif log_format == "keyvalue":
renderer = structlog.processors.KeyValueRenderer()
elif log_format == "console":
renderer = structlog.dev.ConsoleRenderer()
else:
Expand Down

0 comments on commit 8d62d60

Please sign in to comment.