feat: update README, add examples

This commit is contained in:
cătălin 2023-10-02 22:54:20 +02:00
commit 5b600828f6
Signed by: catalin
GPG key ID: 686088EF78EE4083
2 changed files with 31 additions and 21 deletions

View file

@ -6,7 +6,7 @@
[![pdm-managed](https://img.shields.io/badge/pdm-managed-blueviolet)](https://pdm.fming.dev)
Async-compatible, dependency-less, simple log suppression and filtering.
Async-compatible, dependency-less, simple log suppression and filtering lib
## TLDR
@ -15,23 +15,31 @@ Async-compatible, dependency-less, simple log suppression and filtering.
```python
>>> import logging
>>> import shush
>>> logger = logging.getLogger('foo')
>>> @shush.supress
>>> def shouldnt_log():
>>> logging.basicConfig()
>>> logger = logging.getLogger("some_logger")
>>> logger.setLevel(logging.INFO)
>>> @shush.suppress
>>> def suppressed_func():
>>> logger.info("this should not be logged")
>>> @shush.supress
>>> async def shouldnt_log_async():
>>> logger.info("this should not be logged")
>>> def should_log():
>>> @shush.suppress
>>> def normal_func():
>>> logger.info("this should be logged")
>>> shouldnt_log()
>>> await shouldnt_log_async()
>>> should_log()
INFO: this should be logged
>>> suppressed_func()
>>> normal_func()
INFO:some_logger:this should be logged
```
- muzzle text
- muzzle text
```python
>>> import logging
>>> import shush
>>> logging.basicConfig()
>>> logger = logging.getLogger("some_logger")
>>> logger.setLevel(logging.INFO)
>>> @shush.muzzle("foo")
>>> def muzzled_func():
>>> logger.info("this contains `foo`, so it should be muzzled out")
>>> logger.info("this doesn't contain it, so it should be showing")
>>> muzzled_func()
INFO:some_logger:this doesn't contain it, so it should be showing\n
```