Doesn't print line number or file name
yehyaumar opened this issue · 3 comments
When logging, it doesn't show the line number or file name of the log. Instead it shows this
consoleTransport.js:40
when logging.
How to print the line number and file name with this logger?
I am not sure this is possible. The console reader prints the line the log statement was issued and that should be a problem for all JS logging solutions.
And even if there would be a way to specify the source file and line number, one would have to still find this out. Since you have no source information at runtime accessible one would have to create a temp exception, catch it, inspect its callstack and extract a couple of lines back from it to find the source of call.
But I think the best way is to modify the console transport to use console.info.bind(console, timestamp, level, msg)
. That way the line number should be the one of the caller.
This would all be easier, if this library would just patch console.log
functions in the first place and add the transports on top of that. This would also be a drop-in replacement for already existing console.log
etc calls in apps sources. See #61
Even doing the bind to console or try to parse an error stack, react-native creates a js bundle that makes it impossible to trace back to the right file and line number. We need to work on source-maps, as I believe expo logs do. for now I'll leave the issue open until a fairly simple solution is found.