MCLogger: Multi color logger to log to screen and file
MCLogger to log to file AND to the console
What problem does this solve?
A challenge for web-server applications (e.g. such as Flask) is to decipher what's going on from a long logging window. The standard loggers are all single color console test which you have to trawl through manually one by one.
MCLogger helps to solve this by colorising the debug, info, warning, into different colors so that it is much easier to read. The logger will output to both on screen and also a file
How does it do this?
MCLogger builds on the logging library and adds console color libraries to add colors to debug, info, error, warning entries
- DEBUG - blue
- WARNING - yellow
- ERROR - red
- INFO - cyan
How to install?
MCLogger is avaialble through PyPi and you may use pip:
pip install mclogger
Or, through git:
git clone https://github.com/pub12/mclogger.git
How to use the logger?
The logger is super easy to use. You need to simply create an instance and add a file/filepath for the logfile
from mclogger import MCLogger
filename = 'log_file.txt'
logger = MultiLogger(filename).getLogger()
logger.debug("hello world - debug")
logger.info("hello world - info")
logger.error("hello world - error")
logger.warning("hello world - warning")
Output will be:
Class Methods overview
-
getLogger(filename):
Generates the log instance which can be called with .debug(message); .info(message); .error(message); .info(message) which will be displayed in color format.
Format of the output message will be: "
<current server timestamp> [<Filename and line number - function name()>] [<DEBUG | INFO | WARN | ERROR >] - < Message >"- filename - filename with optional relative of optional filepath - e.g.
temp/log_file.txt
- filename - filename with optional relative of optional filepath - e.g.
-
read_log_file(last_n_rows = 20):
Return in an array the
last_n_rowsin an array in the order listed within the file. This will include the color codes for the message- last_n_rows - Number of lines to read
-
read_log_file_as_text(last_n_rows = 20):
Return in an array the
last_n_rowsin an array in the order listed within the file. This will have color codes removed- last_n_rows - Number of lines to read
Metadata
Release files for mclogger 1.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mclogger-1.0.9.tar.gz | 4.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mclogger-1.0.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.9 kB
Release files / mclogger-1.0.9.tar.gz
| Download URL | mclogger-1.0.9.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4a4600bda7f95ba47389fe007e595f6f68cf4589ccf81bfa095c309d6f08a91c
|
|
BLAKE2b-256 checksum How to use checksums |
dac5d65ee8b09725df6b9630dfd4c9b042c3bc908571590f48b696740458afb0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.8.10 Linux/5.4.0-107-generic
|
Release files / mclogger-1.0.9-py3-none-any.whl
| Download URL | mclogger-1.0.9-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
62f6e12823baecd892a87e6bb3445276dead31d3bd4042d15191d18b5c67fb32
|
|
BLAKE2b-256 checksum How to use checksums |
a2e5300c3fa55b3d2885b19a390c68219d539e2edaaf9e79180df8ceae00ca3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.8.10 Linux/5.4.0-107-generic
|