id_translation.logging#
Logging utilities; see Logging for help.
Module Attributes
Set to enable additional |
|
Namespace root logger. |
Functions
|
Enable verbose logging. |
|
Generate a new task ID. |
|
Construct event_key value. |
- ENABLE_VERBOSE_LOGGING = False#
Set to enable additional
DEBUG-level messages.The default (
False) is controlled by theID_TRANSLATION_VERBOSEvariable. Useenable_verbose_debug_messages()to enable temporarily.
- LOGGER = <Logger id_translation (WARNING)>#
Namespace root logger.
Level is set to
logging.WARNING=30by default (orDEBUGifENABLE_VERBOSE_LOGGINGis set). See Logging for details.
- enable_verbose_debug_messages(level='verbose', *, use_custom_handler='auto', style='pretty')[source]#
Enable verbose logging. May be used as a context.
Styles
minimal: Nothing but the logged message itself.
basic: Adds logger name and level.
pretty: Adds basic color and task ID (e.g.
🍏 0x2b92). Mark stage (enter=🚀, exit=✅). Sample output: info, debug, verbose.rainbow: Indent based on stage (requires
level="verbose"). Full-color syntax highlighting for strings and keywords. Sample output: debug, verbose.
- Parameters:
level – Log level. If ‘verbose’ (default), set
ENABLE_VERBOSE_LOGGINGtoTrue.use_custom_handler – Set to
Falseto use existing handlers. If ‘auto’ (default), use existing handlers if one is found (seelogging.Logger.hasHandlers()). IfTrue, propagation is disabled for thenamespace root logger.style – Formatting style to use. Ignored when use_custom_handler evaluates to
False.
Examples
Basic usage.
>>> from id_translation.mapping import Mapper >>> with enable_verbose_debug_messages(): ... # Context manager; changes are temporary. ... Mapper().apply("ab", candidates="abc")
Forcing custom handlers. These add formatting (e.g. color) to namespace logger messages.
>>> enable_verbose_debug_messages(use_custom_handler=True, style="rainbow") >>> Mapper().apply("ab", candidates="abc")
The changes aren’t automatically undone if a regular function call is used.
Notes
Custom handlers emit to standard out.