user2712982
user2712982

Reputation:

Node JS bunyon logging - How to customize to add method name, class name, time of execution, line number in log

Is there a configuration parameter for Node JS bunyan where each log can include the corresponding line number, method and class respectively.

Upvotes: 0

Views: 726

Answers (2)

Jayant Jaiswal
Jayant Jaiswal

Reputation: 181

Using {src:true} option would let node trace the complete path of the file the log has come from leading to do expensive task. You can implement your own class for that and initiate it in every module of the app. Refer to this issue answered by me to make things clear github issue

You can modify things accordingly to add the other info that you want.

Upvotes: 0

Tzvika Mordoch
Tzvika Mordoch

Reputation: 193

When you initialize bunyan you can use src: true

bunyan.createLogger({src: true})

It will add the source file, line and function to the log records

https://www.npmjs.com/package/bunyan#src

Upvotes: 1

Related Questions