A little helper to log warnings/errors for processed
Project description
Looplog
Looplog is a simple helper to log processing done in a loop, catching errors and warnings to produce a readble console output, both interactively and not.
Quickly see how it looks with the demo.
python -m looplog.demo
Usage
Decorate you function with @looplog(items)
like this.
from looplog import SKIP, looplog
@looplog([1, 2, 3, 4, 5, 6, 7, 8, "9", 10, 11.5, 12, 0, 13, None, 15])
def func_basic(value):
if value is None:
return SKIP
if isinstance(value, float) and not value.is_integer():
warnings.warn("Input will be rounded !")
10 // value
# [to stdout in realtime]
# Starting loop `func_basic`
# ..........!.X.-....X.
print(func_basic.details())
# ================================================================================
# WARNING step_11: Input will be rounded !
# ================================================================================
# ERROR step_13: integer division or modulo by zero
# ================================================================================
# ERROR step_20: unsupported operand type(s) for //: 'int' and 'str'
# ================================================================================
print(func_basic.summary())
# 17 ok / 1 warn / 2 err / 1 skip
print(func_basic.report())
# Errors:
# 1 TypeError
# 1 ZeroDivisionError
# Warnings:
# 1 UserWarning
Check the looplog docstring for some additional features (logging, limit, etc.).
Contribute
# install pre-commit
pip install pre-commit mypy
pre-commit install
# run tests
python -m looplog.tests
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
looplog-0.0.12.tar.gz
(8.9 kB
view details)
Built Distribution
File details
Details for the file looplog-0.0.12.tar.gz
.
File metadata
- Download URL: looplog-0.0.12.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 096f54e59f3110664ab506de9619a34305320d02392e1d46ae179c9ccf25c576 |
|
MD5 | d26b2fdc80dd7426e13883c55f811f89 |
|
BLAKE2b-256 | 7c78183096199266bbfe2cf6a9d0e0f37dd29fe3c525bdb78cb615abda929ee7 |
File details
Details for the file looplog-0.0.12-py3-none-any.whl
.
File metadata
- Download URL: looplog-0.0.12-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c9a10089ff902dd1c6bd70ec71a575c67f4e798ecd365d22ee8909d1ea87ba3 |
|
MD5 | 0ce964aed34bef326e5d1f19743069e8 |
|
BLAKE2b-256 | 08babf35c62fc698456e1ecfb209babb2bef4f1dbc83f2056cc470054119de24 |