For every logger statement with any level, I need to display the file name from where the log statement executed, below is the illustration I given below:
Example :
Below is the line executed from JobWork.js
logger.info("getInCompleteJobs in job works");
Actual :
2012-11-05T06:07:19.158Z - info: getInCompleteJobs in job works
Required :
2012-11-05T06:07:19.158Z - info JobWork.js : getInCompleteJobs in job works
Without passing the fileName as a parameter from the log statement it should give the filename.
You can use the stack trace information attached to v8’s
Errorobject to find out what file/line your code was called from. This approach works well, but it does not perform well; so you will want to disable it in production.So you could do something like this: