semvec/pypi-packages huggingface dataset:
looplog 0.0.16
A little helper to log warnings/errors for processed
License: MIT License
Requires Python: >=3.0
Keywords: logging, warnings, errors

# 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.

```bash
python -m looplog.demo
```

## Usage

Decorate you function with `@looplog(items)` like this.

```python
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

```bash
# install pre-commit
pip install pre-commit mypy
pre-commit install

# run tests
python -m looplog.tests
```