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) [![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 ## TLDR
@ -15,23 +15,31 @@ Async-compatible, dependency-less, simple log suppression and filtering.
```python ```python
>>> import logging >>> import logging
>>> import shush >>> import shush
>>> logging.basicConfig()
>>> logger = logging.getLogger('foo') >>> logger = logging.getLogger("some_logger")
>>> @shush.supress >>> logger.setLevel(logging.INFO)
>>> def shouldnt_log(): >>> @shush.suppress
>>> def suppressed_func():
>>> logger.info("this should not be logged") >>> logger.info("this should not be logged")
>>> @shush.suppress
>>> @shush.supress >>> def normal_func():
>>> async def shouldnt_log_async():
>>> logger.info("this should not be logged")
>>> def should_log():
>>> logger.info("this should be logged") >>> logger.info("this should be logged")
>>> suppressed_func()
>>> shouldnt_log() >>> normal_func()
>>> await shouldnt_log_async() INFO:some_logger:this should be logged
>>> should_log()
INFO: 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
```

View file

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