Closed tkutcher closed 4 years ago
Ow! I would like for you to add your workaround for the colorless IDE terms to the README as to help others.
Sounds good, thanks for the feedback! Later this evening I'll clean up those things, squash the cleanup commits, and add to the README for it on this branch.
-Tim
Cleaned up and squashed relevant commits. So now there is one commit for the source code, and one for the note in the README.
Thanks and let me know if there's anything else!
Well done man! Thanks for you contribution. I'll be releasing a new version with this shortly.
Hi - new to Flutter/Dart but this has been a helpful package. This pull request would add two
LogPrinter
decorators.1)
PrefixPrinter
in prefix_printer.dart This allows you to wrap any logger with a prefix to all of it's logs. Inspiration for this being #2 and the AndroidStudio grep-console plugin. But this could also be used just in general to decorate any logger:for example would add prefixes (
"DEBUG"
,"INFO"
, etc.) to each line in thePrettyPrinter
output. But since it is a decorator you could use the same thing for any other printer.It also has optional params for each log level to specify the prefix:
Light unit tests in prefix_printer_test.dart
2)
HybridPrinter
in hybrid_printer.dart This allows you to use a different printer for specific log levels. Inspiration for this is that I found with my logs if they were debug logs, I just wanted a simple one-line view of the log, and with regular logs the fullPrettyPrinter
log. With theHybridPrinter
you can accomplish that like:Same thing as above where there are parameters for each level.
Light unit tests in hybrid_printer_test.dart
So, just for fun, using them together (how I currently am):
The workaround for #2 thus becomes turning colors off, and using prefixes you want for the grep console plugin. Not a full fix, but works nicely for me!
Thought I'd submit this MR in hopes you wanted to add it to the project (also wasn't sure to submit it to master or another branch). Project is awesome! I think these could help with more flexibility in people's own loggers. In general, I would be happy to contribute.
Cheers,
Tim