Skip to main content

🐱‍👓 cobra-log 🐱‍👓
Exception-Aware Logging for Python with Rich Console Output

PyPI version Python codecov License

Tests Github stars

About

cobra-log is a lightweight Python logging library that combines standard logging with exception-friendly workflows and richer terminal output.

  • Python: 3.9+

Features

  • 🚀 Exception-integrated logging API: critical, error, and warning can return/raise typed exceptions while recording context and stack info.
  • 🚀 Rich terminal presentation: A custom console formatter supports styled output, bordered exception traces, and optional color support.
  • 🚀 Flexible handler management: Easy logger activation plus console, stdout, and rotating file handlers with per-handler levels and conflict/overwrite control.

Installation

Install from PyPI

This installs the core package with minimal dependencies.

pip install cobra-log

Install with Optional Dependencies

color support.

pip install cobra-log[color]

Quick Start

  • Simple warning:

    from cobra_log import warning, use_logger
    
    use_logger("your_log_file.log")
    
    warning("warning message")
    
  • Basic usage:

    from cobra_log import (use_logger, info, warning, error)
    
    # initialize and activate loggers
    use_logger("my_logger_1", "stdout", "console")
    use_logger("my_logger_2", "log_save_path.log", ("stdout", "error"))
    # use my_logger_2
    try:
        try:
            try:
                1 / 0
            except Exception as e:
                raise error("An error occurred.", throw=None) from e
        except Exception as ee:
            raise error(
                "An error(TimeoutError) occurred.",
                throw=TimeoutError
            ) from ee
    except Exception:
        critical("A critical error occurred.", throw=None)
    # activate my_logger_1
    use_logger("my_logger_1")
    # use my_logger_1
    warning("A warning occurred.")
    info("An info occurred.")
    

Requirements

  • Python >= 3.9
  • (Optional) cobra-color >= 1.3.13

License

See LICENSE in the repository.

Metadata

Release files for cobra-log 2.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cobra-log 2.0.4
File Size Uploaded Provenance Actions
cobra_log-2.0.4.tar.gz 18.8 kB Without provenance Details for cobra_log-2.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cobra-log 2.0.4
File Interpreter ABI Platform Actions
cobra_log-2.0.4-py3-none-any.whl Python 3 none any Details for cobra_log-2.0.4-py3-none-any.whl

Total release size: 39.2 kB

Release files / cobra_log-2.0.4.tar.gz

Download URL cobra_log-2.0.4.tar.gz
Size 18.8 kB
Tags Source
SHA-256 checksum
How to use checksums
98d1d3d46a87524d38d237c3fcb5c2ed74306f26c2f85c9a596c1190eb900bb5
BLAKE2b-256 checksum
How to use checksums
fe7bab57ef7bf6cf5f8aa105786057bc1bfdf72c1c73418c0cffdd8677da3937
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.10

Release files / cobra_log-2.0.4-py3-none-any.whl

Download URL cobra_log-2.0.4-py3-none-any.whl
Size 20.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b50158c289a6ddb2f2494658496fbb2bc4970498889f61677bfb4fa432b5a276
BLAKE2b-256 checksum
How to use checksums
745c0212fbfa95d75cc2ad51629b7f15730ad35645470cea13b21cff11ed173b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.10

Security for cobra-log 2.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page