logger-color
Color the log message headers and add more logging levels for diagnostics: DIAG_INFO, DIAG_WARNING.
Level |
Int |
Color |
|---|---|---|
DEBUG |
10 |
gray |
INFO |
20 |
green |
WARNING |
30 |
yellow |
ERROR |
40 |
red |
CRITICAL |
50 |
bold red |
DIAG_INFO |
21 |
blue |
DIAG_WARNING |
31 |
purple |
Requirements
Python >=3.8,<3.12
Installation
Install the package from pypi.org release
pip install logger-color
or install the package from github.com repository
pip install git+https://github.com/vladimirs-git/logger-color
start_logging()
start_logging(filename, mode, level, level_file, color, debug) - Start logging with the specified parameters
Parameters
Parameter |
Type |
Default |
Description |
|---|---|---|---|
filename |
str |
Writes messages to this file. By default, logging only to the terminal |
|
mode |
str |
“w” |
“w” - Writes to file (default), “a” - Appends to file |
level |
str |
INFO |
Logging level for the terminal: “DEBUG”, “INFO” (default), “WARNING”, “ERROR”, “CRITICAL”, “DIAG_INFO”, “DIAG_WARNING” |
level_file |
str |
level |
Logging level for the file. By default, the same as level parameter |
color |
bool |
True |
True - Prints a colored message to the terminal (default), False - Prints a monochrome message to the terminal |
debug |
bool |
False |
True - Sets logging level to DEBUG (rewrites level parameter), works the same as level=”DEBUG”. False - Gets logging level from level parameter (default) |
debug()
debug(args, kwargs) - Log a message with severity “DEBUG”
diag_info()
diag_info(msg, args, kwargs) - Log diagnostic message with severity “INFO”
diag_warning()
diag_warning(msg, args, kwargs) - Log diagnostic message with severity “WARNING”
info()
info(args, kwargs) - Log a message with severity “INFO”
warning()
warning(args, kwargs) - Log a message with severity “WARNING”
error()
error(args, kwargs) - Log a message with severity “ERROR”
critical()
warning(args, kwargs) - Log a message with severity “CRITICAL”
Example
import logger_color
logger_color.start_logging(filename="/var/log/test.log", level="debug", level_file="error")
logger_color.debug("debug")
logger_color.info("info")
logger_color.warning("warning")
logger_color.error("error")
logger_color.critical("critical")
logger_color.diag_info("diag_info")
logger_color.diag_warning("diag_warning")
# 2024-10-19 11:03:25.691 DEBUG functions.debug: debug
# 2024-10-19 11:03:25.691 INFO functions.info: info
# 2024-10-19 11:03:25.691 WARNING functions.warning: warning
# 2024-10-19 11:03:25.691 ERROR functions.error: error
# 2024-10-19 11:03:25.691 CRITICAL functions.critical: critical
# 2024-10-19 11:03:25.691 DIAG_I examples_messages.<module>: diag_info
# 2024-10-19 11:03:25.691 DIAG_W examples_messages.<module>: diag_warning
# cat /var/log/test.log
# 2024-10-19 11:03:25 ERROR error
# 2024-10-19 11:03:25 CRITICAL critical
Metadata
Release files for logger-color 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| logger_color-0.2.0.tar.gz | 9.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| logger_color-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.3 kB
Release files / logger_color-0.2.0.tar.gz
| Download URL | logger_color-0.2.0.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
742ca2411cfbc75404d15fde1fded22d188a0d2ac5a9631fc49955f51ab0d712
|
|
BLAKE2b-256 checksum How to use checksums |
184676727136769a4048af1a67c93a27fce5190182281c272b82b21e2797a7b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.10
|
Release files / logger_color-0.2.0-py3-none-any.whl
| Download URL | logger_color-0.2.0-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
223653bf01e60b71a7c0550876f56a70d9c43662caddaed5da17d16d88fdd3cf
|
|
BLAKE2b-256 checksum How to use checksums |
13191fbc00ce9a644a0c6a5866ecbdeb292cc785f15782a5b0af80edc636cc2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.10
|
Security for logger-color 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.