feat: update README, add examples
This commit is contained in:
parent
bdf9e90efa
commit
5b600828f6
2 changed files with 31 additions and 21 deletions
42
README.md
42
README.md
|
|
@ -6,7 +6,7 @@
|
|||
[](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
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue