A lightweight and easy-to-use logging library for Python.
Project description
About
A lightweight and easy-to-use logging library for Python.
- Python: 3.9+
Features
- 🚀 Seamless integration with Python's native exception mechanism.
- 🚀 Vivid and detailed terminal output (need
cobra-color). - 🚀 User-friendly log file management.
Installation
Stable (once published):
pip install cobra-log
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.0
License
See LICENSE in the repository.
Links
Project details
Release history Release notifications | RSS feed
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.0.tar.gz
(17.7 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.0-py3-none-any.whl
(19.5 kB
view details)
File details
Details for the file cobra_log-2.0.0.tar.gz.
File metadata
- Download URL: cobra_log-2.0.0.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03644093858a39a505988fce40929e12370265b9b85744bbff28e7e02045a0a9
|
|
| MD5 |
9b09655dfa659a62aea93c9a45788d6e
|
|
| BLAKE2b-256 |
a0e5ff60fea1f9712e221094e0758671fab502cdc0fbc814bc4652e29bebad19
|
File details
Details for the file cobra_log-2.0.0-py3-none-any.whl.
File metadata
- Download URL: cobra_log-2.0.0-py3-none-any.whl
- Upload date:
- Size: 19.5 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 |
89499754dc4f2712b32df0fb48b06ff5467d339deba5364e290405caef9be943
|
|
| MD5 |
6e81209669af7a0db39495d7a0219cfc
|
|
| BLAKE2b-256 |
7efdd7a3e5d693d13497b2da33ce2282a389b430b67f2cb2878280af108c8f74
|