loggingtools package¶
Subpackages¶
Submodules¶
loggingtools.cli module¶
loggingtools.config module¶
loggingtools.log_with module¶
-
loggingtools.log_with.
format_args
(args, kwargs, arg_names, ignore=set())[source]¶ Format args
Parameters: - args (tuple) –
- kwargs (dict) –
- arg_names (List[str]) –
Returns: Return type: str
-
loggingtools.log_with.
format_func
(function, qualname=False)[source]¶ Format func
Parameters: function (str) – Returns: Return type: str
-
loggingtools.log_with.
format_time
(timespan, precision=3)[source]¶ Formats the timespan in a human readable form
Parameters: - timespan (float) – Time in seconds.
- precision (int) – Desired precision.
-
loggingtools.log_with.
log_with
(logger=None, loglevel=20, arguments=True, qualname=False, timed=False, ignore=())[source]¶ Logging decorator
Parameters: - logger (Logger|None) – Instance of a logger
- loglevel (int) – Level of logging
- arguments (bool) – Flag whether to log arguments that are passed to the function
- qualname (bool) – Flag whether to use __qualname__ instead of __name__ for getting the name of the decorated function.
- timed (bool) – Flag whether to log the execution time of the function.
- ignore (Iterable[str]) – Argument names to ignore for logging arguments.
Examples
>>> @log_with() >>> def func(): >>> pass
loggingtools.setup_logging module¶
-
loggingtools.setup_logging.
load_config
(filepath)[source]¶ Config dictionary
Parameters: filepath (str) –
Returns: Return type: dict
Raises: ImportError
FileNotFoundError
-
loggingtools.setup_logging.
setup_logging
(path_or_config, logdir='.logs', env_key='LOG_CFG')[source]¶ Setup logging configurations defined by dict configuration.
Parameters: - path_or_config (str|dict) –
- dict: Dictionary config
- str: Path to load dictionary configuration from. Can be json or yaml file.
- logdir (str|None) –
- None: Saves logfiles to current working directory
- str: Saves logfiles to specified directory.
- env_key (str) – Environment key for setting path to logging conf.
References
- path_or_config (str|dict) –
Module contents¶
-
loggingtools.
setup_logging
(path_or_config, logdir='.logs', env_key='LOG_CFG')[source]¶ Setup logging configurations defined by dict configuration.
Parameters: - path_or_config (str|dict) –
- dict: Dictionary config
- str: Path to load dictionary configuration from. Can be json or yaml file.
- logdir (str|None) –
- None: Saves logfiles to current working directory
- str: Saves logfiles to specified directory.
- env_key (str) – Environment key for setting path to logging conf.
References
- path_or_config (str|dict) –
-
loggingtools.
log_with
(logger=None, loglevel=20, arguments=True, qualname=False, timed=False, ignore=())[source]¶ Logging decorator
Parameters: - logger (Logger|None) – Instance of a logger
- loglevel (int) – Level of logging
- arguments (bool) – Flag whether to log arguments that are passed to the function
- qualname (bool) – Flag whether to use __qualname__ instead of __name__ for getting the name of the decorated function.
- timed (bool) – Flag whether to log the execution time of the function.
- ignore (Iterable[str]) – Argument names to ignore for logging arguments.
Examples
>>> @log_with() >>> def func(): >>> pass