SourceHorizon / logger

Small, easy to use and extensible logger which prints beautiful logs.
https://pub.dev/packages/logger
MIT License
197 stars 33 forks source link

Combine multiple printers #5

Open Bungeefan opened 1 year ago

Bungeefan commented 1 year ago

I would like to be able to combine multiple printers in any variation and any length.

Example:

You want to prefix your log messages with the log level: PrefixPrinterPrettyPrinter

Which could then produce this:

┌──────────────────────────────────────────────
│ 15:20:17.587 (+0:00:00.202000)
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 🐛 DEBUG: Test message
└──────────────────────────────────────────────

Or you want to prefix every line: PrettyPrinterPrefixPrinter

DEBUG: ┌──────────────────────────────────────────────
DEBUG: │ 15:20:17.587 (+0:00:00.202000)
DEBUG: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
DEBUG: │ 🐛 Test message
DEBUG: └──────────────────────────────────────────────

and so on...

Current blockers:

Maybe we should rethink the approach of using List<String>.

Bungeefan commented 1 year ago

Adding feature request by @talhazengin (#22):

PrettyPrinter should have an option to write the log level at the beginning of the log message.

Bungeefan commented 1 year ago

Draft is available under the multiple_printers branch.