rics.utility.logs#
A namespace for logging constants, and a wrapper rics.utility.logs.basic_config() for the standard
logging.basicConfig()-method with defaults which are defined here.
Module Attributes
Default logging format; |
|
Default logging date format; |
Functions
|
Do basic logging configuration with package defaults. |
- FORMAT: str = '%(asctime)s.%(msecs)03d [%(name)s:%(levelname)s] %(message)s'#
Default logging format;
logging.basicConfig(format=FORMAT)Sample:
<date-format>.378 [rics:DEBUG] I'm a debug message!
- DATE_FORMAT: str = '%Y-%m-%dT%H:%M:%S'#
Default logging date format;
logging.basicConfig(datefmt=DATE_FORMAT)Sample:
2022-02-05T11:17:05<logging-format>
- basic_config(rics_level: Optional[Union[int, str]] = None, force: bool = True, **kwargs: Any) None[source]#
Do basic logging configuration with package defaults.
- Parameters
rics_level – Log level for the rics package. Inherit if
None.force – If
True, override existing configuration if it exists.**kwargs – Keyword arguments for
logging.basicConfig().
- Keyword Arguments
<namespace>_level – Log level for the namespace denoted by namespace (without the “_level”-suffix). Use underscores instead of dots for submodules, eg
module.submodule=>module_submodule.
Examples
Basic usage.
>>> from rics.utility.logs import basic_config, logging >>> root_logger = logging.getLogger() >>> basic_config(level=logging.INFO, rics_level=logging.DEBUG) >>> logging.getLogger("rics").debug("I'm a debug message!") >>> root_logger.debug("I'm a debug message!") >>> root_logger.critical("I'm a critical message!") # Doctest: +SKIP 2022-02-05T11:17:05.378 [rics:DEBUG] I'm a debug message! 2022-02-05T11:17:05.378 [root:CRITICAL] I'm a critical message!
The Python
loggingmodule was imported on the same line to save space.