API¶
Logger Factory¶
- class logger.logger_factory.LoggerConfig¶
Bases:
objectGlobal logger configuration.
- Raises
ValueError – When calling
load_env_vars()with wrongLOGGER_LEVELvalue
- classmethod load_env_vars()¶
Load environment variables with
getenv().Tries to load:
Name
Values accepted
Defaults
CH_ENABLED
True, False
True
FH_ENABLED
True, False
False
LOGGER_LEVEL
NOTSET, DEBUG, INFO, WARNING, ERROR, FATAL
INFO
- Raises
ValueError – When the
LOGGER_LEVELvariables has an incorrect value
- logger.logger_factory.get_logger(log_name: str, console_handler_enabled: Optional[bool] = None, file_handler_enabled: Optional[bool] = None, extra_fields: Optional[dict] = None, filename: Optional[str] = None) logging.LoggerAdapter¶
This function returns a
LoggerAdapterwith the specified log_name.LoggerConfighas global variables configuration.Also handler config, if given as parameter, will replace default.
Filename parameter is available for file handler output.
- Parameters
log_name (str) – Name that will identify these logs from others
console_handler_enabled (bool, optional) – Enables console logging, defaults to None
file_handler_enabled (bool, optional) – Enables file logging, defaults to None
extra_fields (dict, optional) – Extra tags to add, defaults to None
filename (str, optional) – Name of the file for file logging, defaults to None
- Returns
Logger
- Return type
Wrapper¶
- class logger.wrapper.LogWrapper(log_name: str, extra_fields: Optional[dict] = None)¶
Bases:
objectBase class that only handles the logger property.
You could make a class that inherits from this and it will give to your class the property
logger, so you can log anything you want.- _make_new_logger_(log_name: str, extra_fields: Optional[dict] = None)¶
Deprecated since version 1.0.3: Use
make_new_logger()instead.
- property logger¶
Log messages