optigob.logger

This module provides a simple logging interface for optigob.

All logging in optigob uses Python’s standard logging module, which allows users to control what messages they see and where they go (console, file, etc.).

Functions:

get_logger: Get a logger instance for a specific optigob module. configure_logging: Quick setup function for common logging configurations.

Example

>>> from optigob.logger import get_logger
>>> logger = get_logger("my_module")
>>> logger.info("This is an informational message")
>>> logger.warning("This is a warning")

Functions

get_logger([name])

Get a logger instance for optigob.

configure_logging([level, log_to_file, format_style])

Configure logging for optigob with sensible defaults.

Module Contents

optigob.logger.get_logger(name=None)

Get a logger instance for optigob.

This function returns a logger that is part of the ‘optigob’ logging hierarchy. All optigob loggers can be controlled together by configuring the root ‘optigob’ logger.

Parameters:

name (str, optional) – Name of the module/component requesting the logger. If provided, logger will be named “optigob.{name}”. If None, returns the root “optigob” logger.

Returns:

A logger instance that can be used to log messages.

Return type:

logging.Logger

Example

>>> logger = get_logger("data_manager")
>>> logger.info("Loading data...")
>>> logger.warning("Parameter validation issue detected")

Note

By default, if no configuration has been done, Python’s logging will only show WARNING level and above. Call configure_logging() to see INFO and DEBUG.

optigob.logger.configure_logging(level=logging.INFO, log_to_file=None, format_style='detailed')

Configure logging for optigob with sensible defaults.

This is a convenience function for common logging setups. Users can call this at the start of their script to control what optigob logs.

Parameters:
  • level (int) – Minimum logging level to display. Options: - logging.DEBUG (most verbose - shows everything) - logging.INFO (normal - shows general info) - logging.WARNING (quiet - only warnings and errors) - logging.ERROR (very quiet - only errors) Default: logging.INFO

  • log_to_file (str, optional) – If provided, logs will be written to this file in addition to the console. If None, logs only go to console. Default: None

  • format_style (str) – How detailed the log messages should be. Options: - “simple”: Just the message - “detailed”: Time, module name, level, and message Default: “detailed”

Returns:

None

Example

>>> # Show all INFO and above messages
>>> configure_logging(level=logging.INFO)
>>> # Only show warnings and errors
>>> configure_logging(level=logging.WARNING)
>>> # Log everything to a file
>>> configure_logging(level=logging.DEBUG, log_to_file="optigob.log")

Note

This function configures the root ‘optigob’ logger. If you need more advanced control, use Python’s logging module directly.