Logging facility for reuse along projects.
Project description
Darca Log Facility is a powerful, flexible, and structured logging utility for Python applications. It provides configurable logging to both console and file, supports log rotation, and allows optional JSON formatting for structured logging.
Features
Configurable logging levels (DEBUG, INFO, WARNING, ERROR, CRITICAL).
File & Console Logging (with log rotation to prevent excessive file sizes).
JSON Logging Format (for structured logs, useful for log processors).
Colored Console Output (using colorlog for improved readability).
Thread-safe Logging (safe for multi-threaded applications).
Dynamically Change Log Level (without restarting the application).
Installation
To install Darca Log Facility, first, clone the repository:
git clone https://github.com/roelkist/darca-log-facility.git
cd darca-log-facility
Then install dependencies using Poetry:
poetry install --with dev,docs
Makefile Usage
This project includes a Makefile to simplify common tasks.
Format code:
make formatRun linting checks:
make lintRun tests:
make testRun pre-commit hooks:
make precommitGenerate documentation:
make docsRun all pre-push checks (format, lint, test, precommit):
make checkRun full CI pipeline (precommit, lint, test):
make ci
Usage
Basic usage example:
from darca_log_facility.logger import DarcaLogger
import logging
# Initialize logger
logger = DarcaLogger(name="my_app", level=logging.INFO).get_logger()
# Log messages
logger.debug("This is a debug message")
logger.info("This is an info message")
logger.warning("This is a warning message")
logger.error("This is an error message")
logger.critical("This is a critical message")
File logging example:
logger = DarcaLogger(name="file_logger", log_directory="logs", log_to_file=True).get_logger()
logger.info("This message will be written to a log file.")
JSON logging example:
logger = DarcaLogger(name="json_logger", log_directory="logs", json_format=True).get_logger()
logger.info("This log is formatted as JSON.")
Configuration Options
DarcaLogger supports multiple configuration options:
Parameter |
Description |
Default Value |
|---|---|---|
name |
Name of the logger |
"app" |
level |
Logging level (DEBUG, INFO, etc.) |
logging.INFO |
log_directory |
Directory to store log files |
"logs" |
max_file_size |
Max size of a log file before rotating |
5MB |
backup_count |
Number of rotated log files to keep |
5 |
json_format |
Whether to format logs in JSON |
False |
Development and Contribution
We welcome contributions! Follow these steps to contribute:
Fork the repository: https://github.com/roelkist/darca-log-facility
Clone your forked repo:
git clone https://github.com/YOUR_USERNAME/darca-log-facility.gitInstall dependencies using Poetry:
poetry install --with dev,docsRun all checks before submitting code:
make checkSubmit a pull request.
Testing
Darca Log Facility uses pytest for testing. To run the test suite, use:
make test
Continuous Integration (CI)
GitHub Actions runs the following pipeline automatically:
Pre-commit hooks: make precommit
Linting: make lint
Testing with coverage: make test
Documentation build: make docs
Coverage and documentation artifacts are uploaded
Run the full pipeline locally with:
make ci
License
This project is licensed under the MIT License.
Contact
GitHub Repository: https://github.com/roelkist/darca-log-facility
Issues & Bug Reports: https://github.com/roelkist/darca-log-facility/issues
Enjoy using Darca Log Facility! 🚀
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 darca_log_facility-0.1.0.tar.gz.
File metadata
- Download URL: darca_log_facility-0.1.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
543365f0bd03dfe81db1c46efeb2f65b9e5e53ce202df3925625cdc34b46561e
|
|
| MD5 |
fbca3039b7e5e63d0d0efb6edb24fabd
|
|
| BLAKE2b-256 |
0ae26002ac87960b49472df164bb1827293d12125118f74f321b5d4c17cb530d
|
File details
Details for the file darca_log_facility-0.1.0-py3-none-any.whl.
File metadata
- Download URL: darca_log_facility-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85a5981c9eb7f25c572646e04963313f9b32001c82780304878955c97fe931d0
|
|
| MD5 |
43d8c8497c14e77edcf39f9956299ea3
|
|
| BLAKE2b-256 |
65e179336f0cb4acc7198f58e79005183f56d9f7c39dd0ac9ca07eca1dbc75a0
|