Skip to main content

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 format
  • Run linting checks:

    make lint
  • Run tests:

    make test
  • Run pre-commit hooks:

    make precommit
  • Generate documentation:

    make docs
  • Run all pre-push checks (format, lint, test, precommit):

    make check
  • Run 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:

  1. Fork the repository: https://github.com/roelkist/darca-log-facility

  2. Clone your forked repo:

    git clone https://github.com/YOUR_USERNAME/darca-log-facility.git
  3. Install dependencies using Poetry:

    poetry install --with dev,docs
  4. Run all checks before submitting code:

    make check
  5. Submit 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

Enjoy using Darca Log Facility! 🚀

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

darca_log_facility-0.1.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

darca_log_facility-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

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

Hashes for darca_log_facility-0.1.0.tar.gz
Algorithm Hash digest
SHA256 543365f0bd03dfe81db1c46efeb2f65b9e5e53ce202df3925625cdc34b46561e
MD5 fbca3039b7e5e63d0d0efb6edb24fabd
BLAKE2b-256 0ae26002ac87960b49472df164bb1827293d12125118f74f321b5d4c17cb530d

See more details on using hashes here.

File details

Details for the file darca_log_facility-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for darca_log_facility-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 85a5981c9eb7f25c572646e04963313f9b32001c82780304878955c97fe931d0
MD5 43d8c8497c14e77edcf39f9956299ea3
BLAKE2b-256 65e179336f0cb4acc7198f58e79005183f56d9f7c39dd0ac9ca07eca1dbc75a0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page