simc / logger

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

Error while logging #119

Closed pnotel closed 2 years ago

pnotel commented 2 years ago

When we log something which is not 'stringable' (which has no toString method), a NoSuchMethod is thrown into pretty_logger.dart:236.

A fix can be to limit message parameter to 'Object' and not 'dynamic' to be sure, the method exists ? maybe ? Or to simply add a try/catch to log what you can ?

I know, it's strange to log a message which has no 'toString' method, but it can occur when you want to log something dynamic coming from a library and you don't know the exact type (in my case, it's sometimes a closure...).

haarts commented 2 years ago

This is the reason why I let it fail: logging something which doesn't have a decent toString method makes little sense.

I do like your Object suggestion. Wouldn't a lambda be an Object too?