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

[Feature] Add 'TAG' options #11

Open Lexycon opened 1 year ago

Lexycon commented 1 year ago

Is there a chance to add a tag feature to the logger?

There was already a PR on the old repo: [Feature] Add 'TAG' options #103

And here is a discussion: https://github.com/simc/logger/issues/68#issuecomment-786637080

The reason for this is, if you have multiple components for example, I use get_it to inject my logger into these components to collect all log data in one place (FileOutput, whatever.). But I can't figure out which log comes from what component. Maybe just an optional tag attribute like the guy did in the PR.

Bungeefan commented 1 year ago

The original PR is creating rather big breaking API changes, which I would like to avoid for the most part. However, as there is currently no way in Dart to add optional positional and optional named parameters in the same method signature, this would require at least some breaking changes anyway.

My two cents on the discussion: It isn't really comparable with Android's Log as this is a static class and after all logger has been created to be usable with multiple instances and possibly a custom PrefixPrinter. On the other side, an optional TAG parameter could be helpful, this would allow people to tag their logging using a single (possibly static) instance.