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
|
||||
```
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ description = "Simple logs supressor and filter"
|
|||
authors = [
|
||||
{ name = "cătălin", email = "catalin@roboces.dev" },
|
||||
]
|
||||
dynamic = ["version"]
|
||||
version = "0.1.0"
|
||||
dependencies = []
|
||||
requires-python = ">=3.10"
|
||||
readme = "README.md"
|
||||
|
|
@ -44,11 +44,13 @@ linters = [
|
|||
"pyright>=1.1.329",
|
||||
]
|
||||
[tool.pdm.build]
|
||||
excludes = ["**/.pytest_cache/**"]
|
||||
excludes = ["**/.pytest_cache/**", "tests/**"]
|
||||
includes = ["shush"]
|
||||
|
||||
[tool.pdm]
|
||||
version = { source = "file", path = "shush/__version__.py" }
|
||||
[build-system]
|
||||
requires = ["pdm-backend"]
|
||||
build-backend = "pdm.backend"
|
||||
|
||||
|
||||
[tool.pytest]
|
||||
mock_use_standalone_module = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue