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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

looplog-0.0.16-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: looplog-0.0.16.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for looplog-0.0.16.tar.gz
Algorithm Hash digest
SHA256 fa488987168b5b772c16babade414e452435dc45539e5708a4cfe7acc5a0375e
MD5 3ef068d2922447ae7b953d3eb67f06cf
BLAKE2b-256 426b2d1e18f9700a90a29a15debd953da3c323dac9b97ae1d84c928c7990adaa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: looplog-0.0.16-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for looplog-0.0.16-py3-none-any.whl
Algorithm Hash digest
SHA256 9527e6718856c1c89ebca9524a78557822a21ee5d0d9771d36dccc0e2f985c8c
MD5 a715381109bcb6b4f4dacfc2c98410cf
BLAKE2b-256 d7baf8f914836f5aab344322fe78c33a58e2f959943b436ab4c5d362708d9729

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page