A custom Python logger configuration with colored console output.
Project description
negogv-log
A lightweight, colorized Python logger configuration designed for quick integration and high readability. This package provides a pre-configured logger that handles both console and file output with sensible defaults.
Features
- 🎨 Colorized Console Output: Enhanced readability with level-specific colors.
- 📁 Split File Logging: Automatically separates logs into:
high_lvl.log: Warnings, Errors, and Critical messages.low_lvl.log: Debug and Info messages.
- 📄 Multiline Support: File logs automatically indent multiline messages for better formatting.
- 🔍 File Origin Tracking: Includes filename and line numbers in logs to easily identify source locations.
- 🛠️ Exception Helper:
log_exceptionfor quick, colorized exception reporting. - 🚫 Level Filtering: Easily exclude specific log levels from the console.
Installation
pip install negogv-log
Quick Start
from negogv_log import setup_logger
# Initialize the logger with a directory for log files
logger = setup_logger(log_dir="logs")
logger.debug("This is a debug message")
logger.info("Application started")
logger.warning("Something might be wrong")
logger.error("An error occurred")
logger.critical("System failure!")
Advanced Usage
Excluding Console Levels
You can exclude specific levels from being printed to the console:
# Exclude only INFO logs from console
logger = setup_logger(log_dir="logs", exclude_console="INFO")
# Exclude multiple levels
logger = setup_logger(log_dir="logs", exclude_console=["DEBUG", "INFO"])
Exception Logging
Use log_exception to print a concise, colorized summary of an exception:
from negogv_log import log_exception
try:
1 / 0
except Exception as e:
log_exception(e)
Multiline Messages
The file logger handles multiline strings gracefully by indenting subsequent lines:
logger.info("This is a\nmulti-line\nmessage")
Configuration
The setup_logger function performs the following:
- Creates the specified
log_dirif it doesn't exist. - Sets up a
StreamHandlerfor console output withCustomFormatter(colors). - Sets up two
FileHandlers:high_lvl.log(Level >= WARNING)low_lvl.log(Level <= INFO)
License
This project is licensed under the MIT License - see the LICENSE file for details.
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
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
File details
Details for the file negogv_log-0.1.7.tar.gz.
File metadata
- Download URL: negogv_log-0.1.7.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d55e8a2821fd0293ec4c7992822631c8fe8874cea0ecc70cf8b6f91eac47d7e
|
|
| MD5 |
864f782e87f89abf65249683ef60793d
|
|
| BLAKE2b-256 |
6b3024c66b2bedbd48e78b7b54ab53cd2c830dd086d692c49341f7d3e663ecc9
|
File details
Details for the file negogv_log-0.1.7-py3-none-any.whl.
File metadata
- Download URL: negogv_log-0.1.7-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afd8870df1d97683cc5c5dc6a567a4d11d229c3ac61d7d41f15c55dc7418fd9b
|
|
| MD5 |
72898a5454141504d51c79565b87d11c
|
|
| BLAKE2b-256 |
d9295036882ebb7d09fc71e69fbbe7b56dde6421c5e4314e62180afc0c12aeff
|