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 :
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(name=None,
min_level: int = logging.WARNING,
logfile: str = None,
logfile_level=None,
color_on_console: bool = True)
nameis the name of the logger. If not set, the name of the module will be used.min_levelis aLogLevelenum and filters log messages on the console (ex :WARNINGwill not printINFOmessages). Default isWARNING.contextis the logging context, you can use"main()"if you use it in__main__for example. Default is"".logfileis the name of your optional log file forDEBUG,INFOandDEBUGmessages. Default isNone(no log file).logfile_levelis aLogLevelenum and filters log messages in the log file (ex :WARNINGwill not printINFOmessages). Default isWARNING.color_on_consoleis a boolean to enable or disable color on the console. Default isTrue.
logging :
logger.log(msg)
# or
logger.log(msg, level)
with default level = LogLevel.INFO.
You can call the loglevel corresonding function too :
logger.debug(msg)
logger.info(msg)
logger.warning(msg)
logger.error(msg)
logger.critical(msg)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ezpylog-2.2.1.tar.gz.
File metadata
- Download URL: ezpylog-2.2.1.tar.gz
- Upload date:
- Size: 20.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
992b55ad9277a5b80876ea17516c30b9027c6b2b15cc1d6e3e3c1ac344f53bf4
|
|
| MD5 |
4f3bf7d97b4ed085ce09baa811b80e13
|
|
| BLAKE2b-256 |
d00d1440dfc27cea909b523312a7697963caab5bacd7da1a220a7507001ec673
|
File details
Details for the file ezpylog-2.2.1-py3-none-any.whl.
File metadata
- Download URL: ezpylog-2.2.1-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10c7d8b53b9f9d947f109cc6e87413ae2bff3d1100758a681d1b0c2f6f3a76fe
|
|
| MD5 |
082469693d9dbfe656af7022c1fff398
|
|
| BLAKE2b-256 |
78942e3c6eacf7ebfaa19bd473fd55b9bf317e0e801bb06657b4e65d227295c0
|