bkbit.utils.setup_logger module

Logger Setup Module

This module provides a utility function to configure and set up logging for an application. The setup_logger function allows for customizable logging levels and output destinations, either to a file or to the console.

Available log levels: - DEBUG - INFO - WARNING - ERROR - CRITICAL

Example usage:

from setup_logger import setup_logger import logging

# Set up the logger to log to a file with INFO level logger = setup_logger(log_level=”INFO”, log_to_file=True)

# Log some messages logger.info(“This is an info message”) logger.error(“This is an error message”)

Functions:
setup_logger(log_level=”WARNING”, log_to_file=False):

Configures and returns a logger with the specified log level and output destination.

bkbit.utils.setup_logger.LOG_LEVELS

A dictionary mapping log level names to their corresponding logging constants.

Type:

dict

bkbit.utils.setup_logger.setup_logger(file_name, log_level='WARNING', log_to_file=False)[source]

Set up a logger with the specified log level and log destination.

Parameters:
  • log_level (str, optional) – The desired log level. Defaults to “WARNING”.

  • log_to_file (bool, optional) – Whether to log to a file. Defaults to False.

Returns:

The configured logger object.

Return type:

logger

Raises:

ValueError – If an invalid log level is provided.