Skip to main content

A nice-looking, minimalist and easy-to-use Python library for logging your Python programs.

Project description

Ezpylog

Minimalistic and easy to use python logger

How to use ?

Import :

Import logger.py the way you want, personnaly I do :

from ezpylog import Logger, LogLevel

Logging Levels :

The level can be as following :

LogLevel.DEBUG
LogLevel.INFO
LogLevel.WARNING
LogLevel.ERROR
LogLevel.CRITICAL

Initialisation :

logger = Logger(min_level = LogLevel.INFO, context = "", inf_file="stdout", error_file="stderr")
  • min_level is a LogLevel enum and filters log messages on the console (ex : WARNING will not print INFO messages). Default is INFO
  • context is the logging context, you can use "main()" if you use it in __main__ for example. Default is ""
  • inf_file is the name of your output file for DEBUG,INFO and DEBUG messages. Default is stdout
  • error_file is the name of your output file for ERROR and CRITICAL messages. Default is stderr

logging :

logger.log(msg)
# or
logger.log(msg, level)
# or
logger.log(msg, level, subcontext)

with default level = LogLevel.INFO and subcontext = ""

Example :

You can find this exemple by calling Logger.loggerdemo()

from logger import Logger, LogLevel

a = 1234567

logger = Logger(LogLevel.DEBUG)
logger.log("Debug message", LogLevel.DEBUG, "context")
logger.log("Info message")
logger.log("Warning message", LogLevel.WARNING, "context")
logger.log(f"Error message {a}", LogLevel.ERROR, "context")
logger.log("Critical message", LogLevel.CRITICAL, "context")

logger2 = Logger(LogLevel.WARNING, "__main__")
logger2.log("Debug message", LogLevel.DEBUG, "subcontextA()")
logger2.log("Info message", LogLevel.INFO, "subcontextB()")
logger2.log("Warning message", LogLevel.WARNING, "subcontextA()")
logger2.log(f"Error message {a}", LogLevel.ERROR, "subcontextB()")
logger2.log("Critical message", LogLevel.CRITICAL)

prints the following :

image

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

ezpylog-1.1.tar.gz (16.3 kB view details)

Uploaded Source

File details

Details for the file ezpylog-1.1.tar.gz.

File metadata

  • Download URL: ezpylog-1.1.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for ezpylog-1.1.tar.gz
Algorithm Hash digest
SHA256 667052f923f1f61ed2cbdfaa92139a2c178529c5dc1c7041e5e0f92e56d64ee7
MD5 07c141b8b24855bfc82dc0d20855cf0e
BLAKE2b-256 32726de48c89bfc61d5735b446a494d46c51337da8fdff51a4bac6a63e722ada

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