lrlna / pino-colada

cute ndjson formatter for pino 🌲🍹
MIT License
245 stars 46 forks source link

pino-colada swallows errors #21

Closed toddself closed 2 years ago

toddself commented 7 years ago

If you log with log.fatal(err, 'something went wrong') you only see `something went wrong' in your log. It would be better if you got your stacktrace so you can see where the error occurred. (It does seem to log objects given post the error message, just not pre)

lrlna commented 7 years ago

@toddself so I get this with log.fatal, is there something else you would like to see? Or am I misunderstanding you?

screen shot 2017-08-04 at 15 14 53
lrlna commented 7 years ago

@toddself i've been thinking a bit more about getting to display this. When you do send over a .fatal() log with an error that is a type error, we print off the trace, i.e. like the one i have a screenshot above. The trace will go underneath the message you send over.

Pino basically flattens out the object you send over in the log. So if I were to log.info({ cute: 'floof'}, 'Here is an info log'), it would have a log like this.

{
 "pid":18802,
 "hostname":"Irinas-MacBook-Pro.local",
 "name":"merry",
 "level":30,
 "time":1507229693877,
 "msg":"It login",
 "parent":"merry:ctx",
 "cute":"floof",
 "v":1
}

I think what we can do as the first thing is displaying the stack trace when we just log error objects, kind of the way it's requested in #17. The other thing I've been thinking of is possibly be able to work with log.debug() and require the user to have a specific object we print off? i.e. log.debug({ debug: myObj }, 'debugging this statement') and then i can format/display the object under the specificdebug` key.

The other thing I was thinking about is formatting the error messages a bit more. There are a few types of errors we work with, the ones that throw definitely need to have the entire trace. but if you're just working with a syntax error, you just need to know the file name, the line number and the type of error (SyntaxError, TypeError, etc). Or something with connection errors could look something like this: only first line when a connection was refused.

screen shot 2017-10-05 at 15 03 02

LMK what you think!

vislamov commented 6 years ago

@lrlna any thoughts on this? having the same issue

TheTechmage commented 2 years ago

I just wanted to put this out there that, while not well-documented, pino-colada will dump an error if there is an "err" key in the pino logs. So if you log your errors like so, then pino-colada will show the error. For example: Logging an error:

logger.fatal({err: err}, 'Uncaught Exception thrown');

Output from Pino-colada: image

I can see about adding some documentation about this behavior to the readme and send in a PR