Update README.md

This commit is contained in:
Elara 2023-09-28 06:22:03 +00:00
parent e80700db20
commit 85e135cf02
1 changed files with 2 additions and 10 deletions

View File

@ -1,18 +1,10 @@
# Logger
Logger is a very simple and fast logger that can write both machine-readable and human-readable logs.
Logger is a simple and fast logger that can write both machine-readable and human-readable logs.
### Why?
I made logger because I really liked zerolog, and especially its `ConsoleLogger`, as it looks really nice in the terminal. I use it in all my command-line applications, but there's an issue. Zerolog can only output in JSON or CBOR, depending on buid tags. It cannot produce human-readable output. Therefore, zerolog has to use reflection to unmarshal JSON generated by the logger and then make human-readable output out of it. This is, in my opinion, incredibly and unnecessarily wasteful, so I made logger. Logger can use any logging implementation that implements the `logger.Logger` interface. I currently have four implementations: `JSONLogger`, `PrettyLogger`, `MultiLogger`, and `NopLogger`. The names should be self-explanatory.
### Who is logger for?
If you need a fast and simple logger, but don't need more advanced features such as context and hooks, logger is for you. It cuts out unnecessary features, providing a very simple codebase that is easy to test and has much less potential for bugs, and it's faster than zerolog while also allowing more flexibility and a similar API.
### Who is logger not for?
If you need more advanced features, such as context and hooks, use either zerolog or the even faster zap library. Logger keeps it as simple as possible, only providing logging and nothing else.
I really like zerolog, and especially its `ConsoleLogger`. I used it in all my command-line applications, but it has an issue. Zerolog can only output in JSON or CBOR. It can't produce human-readable output such as what the `ConsoleLogger` outputs, so zerolog unmarshals JSON generated by the logger and then makes human-readable output out of it. In my opinion, that's incredibly wasteful, so I made a light structured logger that can write logs in whatever format I need. Logger can use any logging implementation that implements the `logger.Logger` interface.
### Benchmarks