EOX GitLab Instance

Skip to content
Snippets Groups Projects
Commit ea20fb93 authored by Bernhard Mallinger's avatar Bernhard Mallinger
Browse files

Setup config for structured logging

parent 3dba3663
No related branches found
No related tags found
1 merge request!12use structlog
...@@ -2,6 +2,7 @@ from os.path import join, dirname ...@@ -2,6 +2,7 @@ from os.path import join, dirname
import logging.config import logging.config
import click import click
import structlog
import yaml import yaml
import jsonschema import jsonschema
...@@ -22,13 +23,20 @@ def setup_logging(debug=False): ...@@ -22,13 +23,20 @@ def setup_logging(debug=False):
{ {
"version": 1, "version": 1,
"disable_existing_loggers": False, "disable_existing_loggers": False,
"formatters": {"brief": {"format": "%(levelname)s %(name)s: %(message)s"}}, "formatters": {
"json": {
"()": structlog.stdlib.ProcessorFormatter,
"processor": structlog.processors.JSONRenderer(),
# For nicer cli output:
# "processor": structlog.dev.ConsoleRenderer(),
},
},
"handlers": { "handlers": {
"console": { "console": {
"class": "logging.StreamHandler", "class": "logging.StreamHandler",
"level": "DEBUG" if debug else "INFO", "level": "DEBUG" if debug else "INFO",
"formatter": "brief", "formatter": "json",
} },
}, },
"root": { "root": {
"handlers": ["console"], "handlers": ["console"],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment