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! 🚀
Release files for darca-log-facility 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| darca_log_facility-0.1.0.tar.gz | 4.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| darca_log_facility-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.1 kB
Release files / darca_log_facility-0.1.0.tar.gz
| Download URL | darca_log_facility-0.1.0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
543365f0bd03dfe81db1c46efeb2f65b9e5e53ce202df3925625cdc34b46561e
|
|
BLAKE2b-256 checksum How to use checksums |
0ae26002ac87960b49472df164bb1827293d12125118f74f321b5d4c17cb530d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / darca_log_facility-0.1.0-py3-none-any.whl
| Download URL | darca_log_facility-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
85a5981c9eb7f25c572646e04963313f9b32001c82780304878955c97fe931d0
|
|
BLAKE2b-256 checksum How to use checksums |
65e179336f0cb4acc7198f58e79005183f56d9f7c39dd0ac9ca07eca1dbc75a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|