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

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


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.14.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

looplog-0.0.14-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file looplog-0.0.14.tar.gz.

File metadata

  • Download URL: looplog-0.0.14.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for looplog-0.0.14.tar.gz
Algorithm Hash digest
SHA256 a07c068d09f0bf57599f0d36d821329af71600cc024bc83593f510379a432652
MD5 8b6421329e29844f1bf2a040337c7b39
BLAKE2b-256 111ddeddc60f645e976ec26a1ef67a80a25af8f436f59c88e295514d49a8949c

See more details on using hashes here.

File details

Details for the file looplog-0.0.14-py3-none-any.whl.

File metadata

  • Download URL: looplog-0.0.14-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for looplog-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 8538fa9770eb823250ca6ceb211431092148f1931c9354dd9165585a929259f0
MD5 9df460fa7ec33c32557d7961b108beb7
BLAKE2b-256 7c6d4b1b9abdb897f0059d93c7499a399bdf6c0111b273851cc2f350193d1bea

See more details on using hashes here.

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