Skip to content

rats.logs


rats.logs

Small package to help configure logging for rats applications.

__all__ = ['ConfigureApplication'] module-attribute

ConfigureApplication(app)

Bases: apps.AppContainer, apps.PluginMixin

Source code in rats/apps/_app_containers.py
def __init__(self, app: Container) -> None:
    self._app = app

execute()

Source code in rats/logs/_app.py
def execute(self) -> None:
    logging.config.dictConfig(
        {
            "version": 1,
            "disable_existing_loggers": False,
            "formatters": {
                "colored": {
                    "()": "colorlog.ColoredFormatter",
                    "format": (
                        "%(log_color)s%(asctime)s %(levelname)-8s [%(name)s][%(lineno)d]: "
                        "%(message)s%(reset)s"
                    ),
                    "datefmt": "%Y-%m-%d %H:%M:%S",
                    "log_colors": {
                        "DEBUG": "white",
                        "INFO": "green",
                        "WARNING": "yellow",
                        "ERROR": "red,",
                        "CRITICAL": "bold_red",
                    },
                }
            },
            "handlers": {
                "console": {
                    "class": "logging.StreamHandler",
                    "level": "DEBUG",
                    "formatter": "colored",
                    "stream": "ext://sys.stderr",
                }
            },
            "loggers": {
                "": {"level": "INFO", "handlers": ["console"]},
                "azure": {"level": "WARNING", "handlers": ["console"]},
            },
        }
    )
    logger.debug("done configuring logging")