Skip to main content

A production-grade, asynchronous logging decorator for Python.

Project description

LogCrest

LogCrest is a high-performance, asynchronous logging framework for Python designed for production-grade tracing and structured logging with minimal overhead. It replaces standard boilerplate with a robust decorator-driven system that ensures execution timing, parent-child correlation (Trace IDs), and machine-readable output.

Core Features

  • Asynchronous Processing: Logs are processed in a background thread using a non-blocking queue to ensure zero impact on application latency.
  • Correlation Tracing: Automatically propagates Trace IDs across nested function calls, allowing for end-to-end request tracking.
  • Dual-Stream Formatting: Outputs colorized, human-readable terminal logs for development and structured JSON for production log aggregators.
  • Zero-Config Readiness: Works out of the box with sensible defaults, while remaining fully customizable via JSON.
  • SOLID Architecture: Built on a modular foundation, making it easy to extend with custom handlers or formatters.

Installation

pip install logcrest

Practical Examples

1. Basic Usage

Decorate any function to automatically log its entry, exit, arguments, and execution time.

from logcrest import log_decorator, log

@log_decorator
def calculate_metrics(data_points):
    log.info(f"Processing {len(data_points)} points")
    return sum(data_points) / len(data_points)

calculate_metrics([10, 20, 30])

2. Request Tracing (Nested Calls)

LogCrest maintains context across function boundaries. A single Trace ID will be shared across all nested decorated calls originating from a root function.

@log_decorator
def validate_user(user_id):
    return user_id > 0

@log_decorator
def process_request(user_id):
    if validate_user(user_id):
        log.info("Request approved")

# Both functions will share the same Trace ID in the logs
process_request(42)

3. Automated Error Handling

LogCrest catches exceptions, logs the full traceback and execution time before the failure, and re-raises the exception for your application to handle.

@log_decorator
def database_operation():
    raise ConnectionError("Lost connection to host")

try:
    database_operation()
except ConnectionError:
    pass # Error is already logged with full context

4. Custom Log Levels

Control the severity of your logs directly through the decorator.

from logcrest import DEBUG, WARNING

@log_decorator(DEBUG)
def low_priority_task():
    log.debug("Internal step completed")

@log_decorator(WARNING)
def sensitive_operation():
    log.warning("System resources running low")

Advanced Configuration

LogCrest looks for a log_config.json in your project root. If not found, it uses internal defaults.

{
  "base_log_dir": "logs",
  "max_log_size": 5242880,
  "backup_count": 3,
  "use_json": true,
  "log_name": "app_system"
}

Development and Testing

LogCrest is built for stability. To run the test suite:

pip install "logcrest[dev]"
pytest

LogCrest ensures your logs are as reliable as your code.

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

logcrest-1.0.1.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

logcrest-1.0.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file logcrest-1.0.1.tar.gz.

File metadata

  • Download URL: logcrest-1.0.1.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for logcrest-1.0.1.tar.gz
Algorithm Hash digest
SHA256 32705f52a285d38f499292a78c1cd45f2ccc675c8b05fc9e31199013842d771a
MD5 426d20220cd0bc94376eaed8bb649e8b
BLAKE2b-256 0c99ac3d881898f9a65ae724b24a679d5a105772745abdcf34d9056ce063d216

See more details on using hashes here.

Provenance

The following attestation bundles were made for logcrest-1.0.1.tar.gz:

Publisher: publish.yml on snehangsude/LogCrest

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file logcrest-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: logcrest-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for logcrest-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fede19398162ede8e9366221ffe4c2c2ab61b51832d67bd720d22f87f2699fa5
MD5 518289d02ae2a613d3c905314dac7a04
BLAKE2b-256 2c6928446d1fcc3b7fe9cfa7cee7798a44595770e101b37503a8e19e3409040c

See more details on using hashes here.

Provenance

The following attestation bundles were made for logcrest-1.0.1-py3-none-any.whl:

Publisher: publish.yml on snehangsude/LogCrest

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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