From 5b600828f60f4a5ae3d9e463c73bde5fe3516af9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?c=C4=83t=C4=83lin?= Date: Mon, 2 Oct 2023 22:54:20 +0200 Subject: [PATCH] feat: update README, add examples --- README.md | 42 +++++++++++++++++++++++++----------------- pyproject.toml | 10 ++++++---- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 2717fc0..cb5c445 100644 --- a/README.md +++ b/README.md @@ -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 \ No newline at end of file +- 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 +``` diff --git a/pyproject.toml b/pyproject.toml index e78ba94..bce449c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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