Skip to main content

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

Check the looplog docstring for some additional features (logging, limit, etc.).

Contribute

# install pre-commit
pip install pre-commit
pre-commit install

# run tests
python -m tests

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

looplog-0.0.10.tar.gz (8.2 kB view hashes)

Uploaded Source

Built Distribution

looplog-0.0.10-py3-none-any.whl (7.7 kB view hashes)

Uploaded Python 3

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