I was about to use winston in my app, then I realised it can't show function name/line number in the log, which I think is pretty important for debugging a server side application.
After some digging, I found an explanation on winston's github issues page here.
They explained very clearly the reason is performance, getting stack trace on every logging call is very expensive.
However, when I looked for winston alternatives, I found a few libraries already provide features to log line number, for example Bunyan, Scribe and Bristol. I looked at Bristol's source code, it has the following comment on getOrigin
function:
/**
* Finds the origin of the Bristol log call, and supplies the file path and
* line number.
* This function uses JavaScriptStackTraceApi to be as fast as possible:
* https://code.google.com/p/v8-wiki/wiki/JavaScriptStackTraceApi
and I found the document about JavaScriptStackTraceApi
here
I'm just curious, is this the same type of stack trace the winston guys were talking about? Is getting line number an inherent issue in nodejs that no logging library can resolve?
I want line number logged but not with the price of heavy performance penalty. Bristol
looks really good, have anyone seen a performance benchmark of it? or a performance benchmark of any logging library with line number feature turned on?