Package: arb-logger
arb_loggerIntroductionarb_loggeris a Python package that provides advanced logging capabilities, including file logging, console logging with colors, and Redis integration. This package aims to simplify and standardize logging for Python applications by offering an easy-to-use interface and configurable options.FeaturesColored console loggingLogging to file with optional log rotationLogging to Redis using streamsCustom log level for STDOUTUncaught exceptions loggingCustomizable log formatUnit tests for key functionalityarb_alertsprogram to listen to Redis streams and send alerts on MacOSInstallationTo install thearb_loggerpackage from PyPI, simply run the following command:pipinstallarb_loggerTo install thearb_loggerpackage from source, simply clone the repository and install it usingpip:gitclonehttps://github.com/yourusername/arb_logger.gitcdarb_logger
pipinstall.UsageBasic UsageHere's an example of how to create a logger with default settings:fromarb_loggerimportget_logger# The name of the logger will be the name of the calling module# if you call the logger from the main module (i.e. __name__ == "__main__")# you have to specify the name of the logger, if you call it from a module# the name of the logger will be the name of the module automaticallylogger=get_logger('basic_logger')logger.debug("Debug message")logger.info("Info message")logger.warning("Warning message")logger.error("Error message")logger.critical("Critical message")Advanced UsageIn this example, we create a logger with custom settings:frompathlibimportPathfromarb_loggerimportget_loggercustom_path=Path("custom_logs")logger=get_logger(name="my_logger",level=logging.DEBUG,path=custom_path,log_in_file=True,short=False,redis_handler=True)logger.debug("Debug message")logger.info("Info message")logger.warning("Warning message")logger.error("Error message")logger.critical("Critical message")Code documentationget_loggerget_loggeris the main function used to create a logger with custom settings.defget_logger(name:str=None,level:int=logging.DEBUG,path:Path=None,log_in_file:bool=True,short:bool=False,redis_handler:bool=True,custom_redis_client:Redis=None)->logging.Logger:Parametersname: The name of the logger. Defaults to the name of the calling module.level: The minimum log level to log messages. Defaults to logging.DEBUG.path: The directory where log files will be saved. Defaults to None, which means the default log directory will be used.log_in_file: Whether to log messages to a file. Defaults to True.short: Whether to use a short log filename without the process ID. Defaults to False.redis_handler: Whether to use a Redis handler for logging. Defaults to True.custom_redis_client: A custom Redis client to use for logging. Defaults to None, which means a new Redis client will be created using theget_redis_log_client()method insidelogger.py.ReturnsA logger with the specified settings.arb_alertsarb_alertsis a script that listens for log messages from a Redis channel and processes them. It logs the messages to a local logger and sends macOS notifications for messages with log level ERROR or higher.Featuresarb_alertsListens for log messages on a Redis channel.Logs the messages to a local logger.Sends macOS notifications for messages with log level ERROR or higher.