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
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.9
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.2.tar.gz
(18.0 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.2-py3-none-any.whl
(19.7 kB
view details)
File details
Details for the file cobra_log-2.0.2.tar.gz.
File metadata
- Download URL: cobra_log-2.0.2.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c8dafb029f3494ff4fc753ee986cd3c74deb7c0b1668e4968b99e1b8a813309
|
|
| MD5 |
302386dabbd1741ab369be194d1c04f1
|
|
| BLAKE2b-256 |
77dffa9219042bc614ce9a0343581d47edaa5ec27931e5ba592f8ea972d2adf4
|
File details
Details for the file cobra_log-2.0.2-py3-none-any.whl.
File metadata
- Download URL: cobra_log-2.0.2-py3-none-any.whl
- Upload date:
- Size: 19.7 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 |
55e4c415b125d60dea6cf1a1567d8185f61f7c77c929abf1774a4e802e4ea9ab
|
|
| MD5 |
38daf1c4cd1b7a98444e763f664a2b53
|
|
| BLAKE2b-256 |
494c4dc700185ee57762d22ed7614de7cb4c74f57de5fd81cd13c44e2be4952e
|