python logging extensions supporting additional levels, colorization and more
Project description
pylogx
python logging extensions supporting additional levels, colorization, indentation and more
Features
- Additional log levels (HINT, NOTE, TRACE) for more granularity
- Colorize log messages based on the log level
- Indent log messages
- Log relative time stamps
Documentation
- Check the pylox documentation for more details.
Quickstart
Colorize your log messages
import time
import pylogx
from pylogx import log
pylogx.enable_colors(level=pylogx.Level.NOTE, ups=[pylogx.Level.NOTE])
log.trace("Have fun with colorized log messages")
log.note("This message disappears with the next log message")
time.sleep(5)
log.note("Another message disappearing soon..")
time.sleep(5)
log.success("Last message is gone")
Indent your log messages
import logging
from pylogx import log, Indent
formatter = logging.Formatter(fmt="%(asctime)s %(indent)s%(message)s")
sh = logging.StreamHandler()
sh.setFormatter(formatter)
log.addHandler(sh)
indent = Indent(indent=" => ")
log.info("base level")
indent.inc()
log.info("sub level")
indent.inc()
log.info("sub sub level")
indent.dec()
log.info("sub level")
Print log messages with relative time stamp
import time
import logging
from pylogx import log, PrettyDelta, Level
pd = PrettyDelta()
prd = PrettyDelta(name="prettyRelativeDelta", fmt="+%M:%S.%f", relative=True)
log.addFilter(prd)
formatter = logging.Formatter(fmt="%(prettyDelta)s [%(prettyRelativeDelta)s] %(message)s")
sh = logging.StreamHandler()
sh.setFormatter(formatter)
log.addHandler(sh)
log.setLevel(Level.INFO)
log.warning("enjoy relative timestamps")
time.sleep(1)
log.info("enjoy relative timestamps")
time.sleep(2)
log.info("enjoy relative timestamps")
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
pylogx-1.0.3.tar.gz
(4.5 kB
view details)
Built Distribution
File details
Details for the file pylogx-1.0.3.tar.gz
.
File metadata
- Download URL: pylogx-1.0.3.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d5585f1184eed85345cbb20d6c41a4eb3e1637525e6a390f87a146961e2c028 |
|
MD5 | b310e23de58e2a1d4e6d58193de087ff |
|
BLAKE2b-256 | f074ee30f049caffda60b4123e71a320265484f4f149b21d79718d9c2192069b |
File details
Details for the file pylogx-1.0.3-py2.py3-none-any.whl
.
File metadata
- Download URL: pylogx-1.0.3-py2.py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30f1caa900db163d0b99525b861ec1ecfdafdcea6949a0db006a62529663dcb5 |
|
MD5 | 6719cbb7c77a1410fcce9ff4b58795ef |
|
BLAKE2b-256 | bc82c225041d5c33a9b45e43ff56d0c6d60c0e8f1148a219a8b50b155fff36c2 |