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, andwarningcan 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.
Links
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.4.tar.gz
(18.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
cobra_log-2.0.4-py3-none-any.whl
(20.4 kB
view details)
File details
Details for the file cobra_log-2.0.4.tar.gz.
File metadata
- Download URL: cobra_log-2.0.4.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98d1d3d46a87524d38d237c3fcb5c2ed74306f26c2f85c9a596c1190eb900bb5
|
|
| MD5 |
123858fca1bba0db01207c6f30e3d2f8
|
|
| BLAKE2b-256 |
fe7bab57ef7bf6cf5f8aa105786057bc1bfdf72c1c73418c0cffdd8677da3937
|
File details
Details for the file cobra_log-2.0.4-py3-none-any.whl.
File metadata
- Download URL: cobra_log-2.0.4-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b50158c289a6ddb2f2494658496fbb2bc4970498889f61677bfb4fa432b5a276
|
|
| MD5 |
9aacd1254a6327f6c0c6c98018d9bd87
|
|
| BLAKE2b-256 |
745c0212fbfa95d75cc2ad51629b7f15730ad35645470cea13b21cff11ed173b
|