A nice-looking, minimalist and easy-to-use Python library for logging your Python programs.
Project description
Welcome
ezpylog is a minimalistic and easy to use python logger
Installation
Using pip :
- directly from command line with :
pip install ezpylog
- manually by downloading ezpylog and install it with
pip install ezpylog-X.X.tar.gz
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 aLogLevel
enum and filters log messages on the console (ex :WARNING
will not printINFO
messages). Default isINFO
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 forDEBUG
,INFO
andDEBUG
messages. Default isstdout
error_file
is the name of your output file forERROR
andCRITICAL
messages. Default isstderr
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 ezpylog 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 :
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 Distribution
ezpylog-2.0.4.tar.gz
(17.5 kB
view hashes)