Configurable logging for Python applications
Project description
SIBRA Logger
SIBRA Logger is an configurable logging library designed for Python applications. It supports dynamic configuration reloading, structured logging for seamless integration into any project.
Features
- Dynamic Configuration Reloading:
- Automatically monitors and reloads logging configurations without restarting the application.
Installation
Prerequisites
- Python 3.6 or higher.
Install the Package
pip install sibra_logger
Install Development Dependencies (Optional)
To install dependencies for development and testing:
pip install sibra_logger[dev]
Usage
Basic Setup
- Initialize Logging in Your Application
from sibra_logger import setup_logging, start_logging_monitor
# Set up logging
setup_logging()
# Start monitoring configuration changes
start_logging_monitor()
- Log Messages
import logging
logger = logging.getLogger(__name__)
logger.info("This is an informational message.")
logger.debug("This is a debug message.")
logger.error("This is an error message.")
Using a Custom Configuration File
Pass a custom configuration file path to setup_logging:
setup_logging("path/to/custom_config.yaml")
Storing configuration file as env variable
This logger support storing env variable SIBRA_LOG_CONFIG & pulls the config file from env variable as well.
Configuration
The logging behavior is controlled via a YAML configuration file (log_config.yaml).
Example Configuration
version: 1
disable_existing_loggers: false
formatters:
detailed:
format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s [Line: %(lineno)d]'
datefmt: '%Y-%m-%d %H:%M:%S'
handlers:
console:
class: logging.StreamHandler
level: DEBUG
formatter: detailed
stream: ext://sys.stdout
rotating_file:
class: logging.handlers.RotatingFileHandler
level: INFO
formatter: detailed
filename: logs/rotating_app.log
maxBytes: 10485760
backupCount: 5
encoding: utf8
root:
level: INFO
handlers: [console, rotating_file]
Dependencies
Required
pyyaml: For YAML configuration.
#Contributing Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a feature branch.
- Commit your changes and submit a pull request.
License
This project is licensed under the MIT License. See LICENSE for more details.
This README.md reflects the features and functionality of your package, organized to be user-friendly and professional. Let me know if you'd like any additional adjustments!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sibra_logger-1.0.0.tar.gz.
File metadata
- Download URL: sibra_logger-1.0.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69ca152a39a73e2b63e38d41f341c17efe471472dadaf35dd3ebdb20be434e1e
|
|
| MD5 |
8e9a5d7d56a3fc0f0a1fb265258aec11
|
|
| BLAKE2b-256 |
bf6eca0f075d0b8bb080c5832f6df7cd278bb97fdfa215d39d779ab324985d36
|
File details
Details for the file sibra_logger-1.0.0-py3-none-any.whl.
File metadata
- Download URL: sibra_logger-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d519deaa69adbb30d6bba0adc8e7528c1b8ee806aa56ba5c58be2d9fd8ab461
|
|
| MD5 |
5346febf66cb67ffdd123cd6732f9aea
|
|
| BLAKE2b-256 |
ca60b38bc252b36d6d2aa8cc7ae7757169f7491587f0557d2f843d62359871b7
|