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

Tag field #67

Open pyciko opened 5 months ago

pyciko commented 5 months ago

For big projects with many submodules, it is handy to mark the submodule that sent a log message. For example, if you have a realtime project with Teams, Users and Chats, and certain event parsing for some of these instances has failed, you'd probably want to print something like "[TEAMS] Failed fetching new avatar for team 2352379". That way, it's much easier to notice the desired messages. Basically I'm proposing to add a nullable "tag" field for Logger itself and individual log events (individual tags override Logger tag). This is not done on Printer level because Printer tags can't be individual for each log. I'm not sure about 2 things:

  1. How to format the tag in SimplePrinter: "[SomeTag]" or "TAG: SomeTag. I like the first variant because it's more compact.
  2. Where to put it in PrettyPrinter. Right now it shows at the top of the message.
Bungeefan commented 5 months ago

Thanks for the pull request. However, since it hasn't even been decided yet whether such a feature will be added, let alone how it will be implemented, I can't really review this PR at this time and marked it as a draft for now. Sorry.