A colorful logger for python3.
Project description
python-logger
Colorful logger for python3
How to use
Install
pip install colorful-logger
Usage
You can directly use the default logger, the colored logs will be printed on the terminal, and the default logger level is warning.
from colorful_logger.logger import logger
logger.debug("This is a debug message.")
logger.info("This is a info message.")
logger.warning("This is a warning message.")
logger.error("This is a error message.")
logger.fatal("This is a fatal message.")
You can also change the log level, save the log to a file, change the logger name, and the log may not be output to the terminal.
from colorful_logger.logger import get_logger, DEBUG
logger = get_logger(name="sample_logger", level=DEBUG, file_path="./test.log")
logger.debug("This is a debug message.")
logger.info("This is a info message.")
logger.warning("This is a warning message.")
logger.error("This is a error message.")
logger.fatal("This is a fatal message.")
The contents of the log file:
[DEBUG] 2021-05-21 15:08:42 test.py:8 - This is a debug message.
[INFO] 2021-05-21 15:08:42 test.py:9 - This is a info message.
[WARNING] 2021-05-21 15:08:42 test.py:10 - This is a warning message.
[ERROR] 2021-05-21 15:08:42 test.py:11 - This is a error message.
[CRITICAL] 2021-05-21 15:08:42 test.py:12 - This is a fatal message.
As you can see, the log saved to the file uses the default formatter, so it is not in color.
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file colorful_logger-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: colorful_logger-0.0.3-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0366d2d4591796f3fc3fb906c1a006dd42052a7d9fea85f1ccbefc8e46848061 |
|
MD5 | a015a896d197ca08b8cdf0a6d689a7c5 |
|
BLAKE2b-256 | 4600f5cd65e8291e73374d912265b087b888254afe635d6b3f059aa52592c6d9 |