hbllmutils.utils.logging
Global logger configuration and management utilities.
This module provides centralized logging functionality for the hbllmutils package. It offers a simple interface to access and manage a consistent logger instance that can be used across all components of the application, ensuring uniform logging behavior and configuration throughout the package.
The module contains the following main components:
get_global_logger()- Retrieves the global logger instance for the package
Note
The logger returned by this module follows Python’s standard logging hierarchy, allowing for flexible configuration through the standard logging module.
See also
logging - Python’s built-in logging module for configuration options
Example:
>>> from hbllmutils.utils.logging import get_global_logger
>>> logger = get_global_logger()
>>> logger.info('Application started')
INFO:hbllmutils:Application started
>>>
>>> # Configure logging level for the entire package
>>> import logging
>>> logger.setLevel(logging.DEBUG)
>>> logger.debug('Debug information')
DEBUG:hbllmutils:Debug information
get_global_logger
- hbllmutils.utils.logging.get_global_logger() Logger[source]
Get the global logger instance for the hbllmutils package.
This function returns a logger instance with the name ‘hbllmutils’ that can be used throughout the package for consistent logging. The logger follows Python’s standard logging hierarchy, allowing for centralized configuration.
The returned logger can be configured using standard logging module methods, and all child loggers will inherit the configuration. This ensures consistent logging behavior across the entire package.
- Returns:
The global logger instance for hbllmutils
- Return type:
logging.Logger
Note
This function creates the logger if it doesn’t exist, or returns the existing instance if it has already been created. Multiple calls to this function will return the same logger object.
See also
logging.getLogger()- Python’s standard logger retrieval functionExample:
>>> from hbllmutils.utils.logging import get_global_logger >>> logger = get_global_logger() >>> logger.info('This is an info message') INFO:hbllmutils:This is an info message >>> logger.warning('This is a warning') WARNING:hbllmutils:This is a warning >>> >>> # Configure the logger >>> import logging >>> logger.setLevel(logging.DEBUG) >>> handler = logging.StreamHandler() >>> formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') >>> handler.setFormatter(formatter) >>> logger.addHandler(handler) >>> logger.debug('Detailed debug information') 2024-01-01 12:00:00,000 - hbllmutils - DEBUG - Detailed debug information