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

printing stacktrace not working #76

Closed Priyantha-Kingslake closed 3 months ago

Priyantha-Kingslake commented 3 months ago

Is stacktrace in simplePrinter not working?

final Logger _logger = Logger(printer: SimplePrinter());

try {
  ...
} catch (e, s) {
  _logger.e(e, error: e, stackTrace: s);
}

i expected this to print the stacktrace like print(e) would. Did I do anything wrong?

Bungeefan commented 3 months ago

Hi, unfortunately SimplePrinter does currently not support printing a stack trace, just an error. If you need this feature, either extend the printer yourself and add it in the way you like it or use another printer that supports it (e.g. PrettyPrinter).

Priyantha-Kingslake commented 3 months ago

Thanks for clarifying. Will use PrettyPrinter I'm wondering if this is needed to be documented🤔 Could be confusing since the named parameter stacktrace is available

Bungeefan commented 3 months ago

Probably not a bad idea to clarify it further, however the current class documentation contains an example log line of an error, and it shows that there is no stack trace printed along with it (But yeah not really obvious or clear).

Regarding the parameter, all parameters are always available as the interface is not influenced by the configured printer. You could even write a printer that ignored everything besides the time and the method signature wouldn't be able to adapt.