-
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.
feat: adding logger.py to configure structlog and then implemented it…
… in __main__.py and in the modules
- Loading branch information
1 parent
02832d9
commit df70738
Showing
6 changed files
with
50 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
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'] | ||
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(processors=[*structlog.get_config()["processors"], structlog.processors.JSONRenderer()]) | ||
|
||
def 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from ..module import ModuleHandler | ||
from rookify.logger import getLogger | ||
|
||
class MigrateMonitorsHandler(ModuleHandler): | ||
pass | ||
def run(self): | ||
log = getLogger() | ||
log.info("MigrateMonitorsHandler ran successfully.") | ||
|
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