Utility methods for logging tasks.
Module Attributes
Default logging format; |
|
Default logging date format; |
Functions
|
Do basic logging configuration with package defaults. |
Default logging format; <date-format>.378 [rics:DEBUG] I'm a debug message!
Default logging date format; 2022-02-05T11:17:05<logging-format>
Do basic logging configuration with package defaults.
Simple wrapper for the standard logging.basicConfig()-method, using my personal preferences for defaults.
format – Format string for emitted messages; see FORMAT.
datefmt – Format string for date/time; see DATE_FORMAT.
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().
<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 logging module was imported on the same line to save space.