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

Uploaded Source

Built Distribution

looplog-0.0.13-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: looplog-0.0.13.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

Hashes for looplog-0.0.13.tar.gz
Algorithm Hash digest
SHA256 5fbd05dbf3cbf664443ba371e296dee639d1464900acba4437b3542ad4b30256
MD5 ad60315177780184593320a7149f29ed
BLAKE2b-256 19683fdf1dd9aa102fd3834b051a2f8dac9484a6d0c75e9eca6d2dc64d07d7e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: looplog-0.0.13-py3-none-any.whl
  • Upload date:
  • Size: 8.4 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.13-py3-none-any.whl
Algorithm Hash digest
SHA256 23d4b775cef397f4d4cef5e77750ed5b0adcc14ea2893db9f06e35cf735016a0
MD5 75bdc99d84c59cdfade5997adb184932
BLAKE2b-256 334c7154a468e07e66aa60fc000db8728edcf78cbfac5bb3b86c43fdc4bebb61

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