Skip to content

Commit

Permalink
Merge pull request #7 from pomponchik/develop
Browse files Browse the repository at this point in the history
0.0.7
  • Loading branch information
pomponchik authored Jul 13, 2024
2 parents 393dfa4 + 0e90bc2 commit 3ae1a2d
Show file tree
Hide file tree
Showing 8 changed files with 2,580 additions and 4 deletions.
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# emptylog: some tools for logging
![logo](https://raw.githubusercontent.com/pomponchik/emptylog/develop/docs/assets/logo_5.svg)

[![Downloads](https://static.pepy.tech/badge/emptylog/month)](https://pepy.tech/project/emptylog)
[![Downloads](https://static.pepy.tech/badge/emptylog)](https://pepy.tech/project/emptylog)
Expand All @@ -11,8 +11,17 @@
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

This library is designed to extend the capabilities of the built-in [`logging`](https://docs.python.org/3/library/logging.html) library.

This package ensures compatibility of any logger implementations with the built-in [`logging`](https://docs.python.org/3/library/logging.html) library.
One of the important problems that it solves is the fact that almost no one tests logging in their programs. Are you sure that your program logs everything you need? Programmers cover with tests what they consider to be the basic logic of the program. Logging problems are usually detected only when something is on fire, and then you realize that there are not enough logs, or the wrong thing is being logged. On the contrary, this library makes logging as much a test-friendly part of your program as regular logic.

Here are some of the features it provides:

- A [universal logger protocol](#universal-logger-protocol) that allows you to replace one logger with another without typing violations. In tests, you can replace the original logger with a [logger that remembers its calls](#memory-logger) to check that logging is correct.
- An [empty logger]((#empty-logger)) that does nothing when you call it. It is useful for writing library functions where the user can pass their logger, but there is no logging by default.
- A [memory logger](#memory-logger) that remembers all the times it was called. To verify that your code is correctly logged in, pass it a memory logger object instead of the default logger, and then check how it was used.
- A [printing logger](#printing-logger) is a "toy version" of a real logger that you can use to visualize all logger calls inside your test.
- All loggers presented in this library can be easily [combined](#summation-of-loggers) using the "+" symbol.


## Table of contents
Expand Down Expand Up @@ -215,7 +224,7 @@ print(MemoryLogger() + loguru_logger + logging.getLogger(__name__))
#> LoggersGroup(MemoryLogger(), <loguru.logger handlers=[(id=0, level=10, sink=<stderr>)]>, <Logger __main__ (WARNING)>)
```

Finally, you can use a group as an iterable object, as well as find out the [number of nested loggers](https://docs.python.org/3/library/functions.html#len) in a standard way:
Finally, you can use a group as an iterable object, as well as find out the number of nested loggers in a standard way:

```python
group = PrintingLogger() + MemoryLogger()
Expand Down
Loading

0 comments on commit 3ae1a2d

Please sign in to comment.