Skip to main content

MCLogger that shows log records on screen in color and in a log file

Project description

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: Output for mclogger

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
  • read_log_file(last_n_rows = 20):

    Return in an array the last_n_rows in 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_rows in an array in the order listed within the file. This will have color codes removed

    • last_n_rows - Number of lines to read

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

mclogger-1.0.9.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

mclogger-1.0.9-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file mclogger-1.0.9.tar.gz.

File metadata

  • Download URL: mclogger-1.0.9.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.10 Linux/5.4.0-107-generic

File hashes

Hashes for mclogger-1.0.9.tar.gz
Algorithm Hash digest
SHA256 4a4600bda7f95ba47389fe007e595f6f68cf4589ccf81bfa095c309d6f08a91c
MD5 764ac2cdcff46b1e77a2f292a1adc9e6
BLAKE2b-256 dac5d65ee8b09725df6b9630dfd4c9b042c3bc908571590f48b696740458afb0

See more details on using hashes here.

File details

Details for the file mclogger-1.0.9-py3-none-any.whl.

File metadata

  • Download URL: mclogger-1.0.9-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.10 Linux/5.4.0-107-generic

File hashes

Hashes for mclogger-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 62f6e12823baecd892a87e6bb3445276dead31d3bd4042d15191d18b5c67fb32
MD5 26bb70ce8d54c9d89c9bb67c9b6094e5
BLAKE2b-256 a2e5300c3fa55b3d2885b19a390c68219d539e2edaaf9e79180df8ceae00ca3b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page