Skip to main content

A lightweight Python logging library that combines standard logging with exception-friendly workflows and richer terminal output.

Project description

🐱‍👓 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")
    

Example

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.11

License

See LICENSE in the repository.

Links

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

cobra_log-2.0.3.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

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

cobra_log-2.0.3-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file cobra_log-2.0.3.tar.gz.

File metadata

  • Download URL: cobra_log-2.0.3.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for cobra_log-2.0.3.tar.gz
Algorithm Hash digest
SHA256 e73969cf8a54b8378d901f2a88f9b3b7c5d8e78f20533ecadd2980202a78a9fb
MD5 0608cee984e0b95c498a80c0744314d4
BLAKE2b-256 a332af0fa46c606b423e726408d8028a0f6bc54d4b38ca9a5891ecd3398c7409

See more details on using hashes here.

File details

Details for the file cobra_log-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: cobra_log-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for cobra_log-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f84e7decdad6159321980b94f60dad2b6c956a9a8c07325ceb11252229ed5147
MD5 16e6a468d4d959e65c39354164e34371
BLAKE2b-256 13b8f9de6151a50a5c2172c2b662ba915fa10e818a3a13396358e1016382513e

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