Skip to content

Commit 24e9f21

Browse files
committed
docs: Update README to include HandlerType enum and improve method descriptions
1 parent 7c8c5d8 commit 24e9f21

1 file changed

Lines changed: 27 additions & 8 deletions

File tree

README.md

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
# Logguard
22

3-
[![Python](https://img.shields.io/badge/Language-Python-3776AB?style=flat&logo=python&logoColor=white)](https://www.python.org/)
43
[![Supported Python Versions](https://img.shields.io/pypi/pyversions/py-logguard)](https://pypi.org/project/py-logguard/)
54
[![PyPI](https://img.shields.io/pypi/v/py-logguard?style=flat&logo=pypi&logoColor=white)](https://pypi.org/project/py-logguard/)
6-
7-
![Status](https://img.shields.io/badge/status-beta-yellow?style=flat)
8-
[![license](https://img.shields.io/badge/license-MIT-blue?logo=opensourceinitiative&logoColor=white)](https://raw.githubusercontent.com/DMsuDev/logguard/main/LICENSE.rst)
5+
[![codecov](https://img.shields.io/codecov/c/github/DMsuDev/logguard?style=flat&logo=codecov&logoColor=white)](https://codecov.io/gh/DMsuDev/logguard)
96

107
Logguard is a lightweight logging and assertion library designed to make it easy to capture rich context and structured logs in Python applications. It provides a simple API for logging with automatic source capture, flexible configuration, and a semantic exception hierarchy.
118

@@ -290,12 +287,34 @@ AppLogger.setup(
290287
)
291288
```
292289

290+
**`HandlerType` enum**: use instead of plain strings to select which handlers an operation targets:
291+
292+
| Member | Targets |
293+
| --------------------- | ----------------------------- |
294+
| `HandlerType.ALL` | Every handler (default) |
295+
| `HandlerType.CONSOLE` | Console / RichHandler only |
296+
| `HandlerType.FILE` | RotatingFileHandler only |
297+
| `HandlerType.JSON` | JSON RotatingFileHandler only |
298+
293299
**Methods:**
294300

295-
- `get_logger(name: str | None = None)` - Get or create a logger instance
296-
- `set_level(level: str, handler_type: str = "all")` - Change log level dynamically
297-
- `silence_noisy_libraries(modules: list[str] | None = None)` - Suppress third-party logs
298-
- `reset()` - Reset configuration (useful for testing)
301+
- `get_logger(name: str | None = None)`: Get or create a logger instance
302+
- `set_level(level, handler_type: HandlerType | str = HandlerType.ALL)`: Change log level on selected handlers at runtime
303+
- `set_format(format_string, handler_type: HandlerType | str = HandlerType.ALL, datefmt=None)`: Change the format string on selected handlers; RichHandler and JsonFormatter instances are skipped automatically
304+
- `silence_noisy_libraries(modules: list[str] | None = None)`: Suppress third-party logs
305+
- `reset()`: Reset configuration (useful for testing)
306+
307+
```python
308+
from logguard import AppLogger, HandlerType
309+
310+
AppLogger.setup(log_file="logs/app.log", console_level="INFO")
311+
312+
# Drop file handler to DEBUG without touching the console
313+
AppLogger.set_level("DEBUG", HandlerType.FILE)
314+
315+
# Apply a compact format to file logs only
316+
AppLogger.set_format("%(asctime)s | %(levelname)s | %(message)s", HandlerType.FILE)
317+
```
299318

300319
</details>
301320

0 commit comments

Comments
 (0)