udaan.utils.logging module¶
Structured logging for Udaan library.
This module provides a consistent logging interface for the library. Library users can configure logging through standard Python logging mechanisms.
- Usage:
# In library code from udaan.utils.logging import get_logger logger = get_logger(__name__) logger.info(“Controller initialized”)
# For users to enable logging output from udaan.utils.logging import setup_logging setup_logging() # Enable INFO level output setup_logging(level=logging.DEBUG) # Enable debug output
- class udaan.utils.logging.LoggerMixin[source]¶
Bases:
objectMixin class providing logging capabilities to classes.
Inherit from this mixin to get a _logger property that returns a logger named after the class.
Example
>>> class MyController(LoggerMixin): ... def compute(self): ... self._logger.debug("Computing...")
- udaan.utils.logging.get_logger(name)[source]¶
Get a logger for the given module name.
- Parameters:
name (
str) – Module name, typically __name__.- Return type:
- Returns:
Logger instance under the udaan namespace.
Example
>>> logger = get_logger(__name__) >>> logger.info("Message")
- udaan.utils.logging.setup_logging(level=20, format_string=None, stream=None, color=None)[source]¶
Configure logging for interactive use.
Call this function to enable logging output from Udaan. By default, the library produces no output (NullHandler).
- Parameters:
- Return type:
Example
>>> import logging >>> from udaan.utils.logging import setup_logging >>> setup_logging() # Enable INFO level with colors >>> setup_logging(level=logging.DEBUG) # Enable debug