arb_logger
Introduction
arb_logger is 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.
Features
- Colored console logging
- Logging to file with optional log rotation
- Logging to Redis using streams
- Custom log level for STDOUT
- Uncaught exceptions logging
- Customizable log format
- Unit tests for key functionality
arb_alertsprogram to listen to Redis streams and send alerts on MacOS
Installation
To install the arb_logger package from PyPI, simply run the following command:
pip install arb_logger
To install the arb_logger package from source, simply clone the repository and install it using pip:
git clone https://github.com/acid3croco/arb_logger.git
cd arb_logger
pip install .
Usage
Basic Usage
Here's an example of how to create a logger with default settings:
from arb_logger import get_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 automatically
logger = 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 Usage
In this example, we create a logger with custom settings:
from pathlib import Path
from arb_logger import get_logger
custom_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 documentation
get_logger
get_logger is the main function used to create a logger with custom settings.
def get_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:
Parameters
name: 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.
Returns
A logger with the specified settings.
arb_alerts
arb_alerts is 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.
Features
arb_alerts
- Listens 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.
Metadata
Release files for arb-logger 2.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| arb_logger-2.2.1.tar.gz | 7.2 kB | Without provenance | Details for arb_logger-2.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| arb_logger-2.2.1-py3-none-any.whl | Python 3 | none | any | Details for arb_logger-2.2.1-py3-none-any.whl |
Total release size: 14.2 kB
Release files / arb_logger-2.2.1.tar.gz
| Download URL | arb_logger-2.2.1.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4779f9e9f77fb0f072e67775ce55b89c1fb6d5aeb04384692ea480c806865cb5
|
|
BLAKE2b-256 checksum How to use checksums |
58c0b828e1c111fef08f84415e1428cfc6bcd303642c994d2477b13d42434e63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.7
|
Release files / arb_logger-2.2.1-py3-none-any.whl
| Download URL | arb_logger-2.2.1-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a9b589d08e84a79a0a1efed54ee1b02fc765307124a874253a91d02f67446500
|
|
BLAKE2b-256 checksum How to use checksums |
9e794bb1f155303c42e59bb51221d0071e4b163e5092cd0c80b4981b4d0745ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.7
|
Security for arb-logger 2.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.