-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: adapt example to have corret config path, add typing, add
rudimentary makefile command to download config from testbed Signed-off-by: Rafael te Boekhorst <[email protected]>
- Loading branch information
1 parent
81e54f5
commit 18b306a
Showing
5 changed files
with
38 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,35 @@ | ||
import structlog | ||
import logging | ||
|
||
def configure_logging(config): | ||
LOG_LEVEL = getattr(logging, config['logging']['level']) | ||
LOG_TIME_FORMAT = config['logging']['format']['time'] | ||
LOG_RENDERER = config['logging']['format']['renderer'] | ||
from typing import Any, Dict | ||
|
||
|
||
def configure_logging(config: Dict[str, Any]) -> None: | ||
LOG_LEVEL = getattr(logging, config["logging"]["level"]) | ||
LOG_TIME_FORMAT = config["logging"]["format"]["time"] | ||
LOG_RENDERER = config["logging"]["format"]["renderer"] | ||
structlog.configure( | ||
wrapper_class=structlog.make_filtering_bound_logger(LOG_LEVEL), | ||
processors=[ | ||
structlog.processors.TimeStamper(fmt=LOG_TIME_FORMAT), | ||
structlog.processors.add_log_level, | ||
], | ||
) | ||
if LOG_RENDERER == "console": | ||
structlog.configure( | ||
processors=[ | ||
*structlog.get_config()["processors"], | ||
structlog.dev.ConsoleRenderer(), | ||
] | ||
) | ||
else: | ||
structlog.configure( | ||
wrapper_class=structlog.make_filtering_bound_logger(LOG_LEVEL), | ||
processors=[ | ||
structlog.processors.TimeStamper(fmt=LOG_TIME_FORMAT), | ||
structlog.processors.add_log_level | ||
*structlog.get_config()["processors"], | ||
structlog.processors.JSONRenderer(), | ||
] | ||
) | ||
if LOG_RENDERER == "console": | ||
structlog.configure(processors=[*structlog.get_config()["processors"], structlog.dev.ConsoleRenderer()]) | ||
else: | ||
structlog.configure(processors=[*structlog.get_config()["processors"], structlog.processors.JSONRenderer()]) | ||
|
||
def getLogger(): | ||
|
||
|
||
def getLogger() -> structlog.getLogger: | ||
return structlog.get_logger() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters