Node.js - getting current filename

后端 未结 8 862
执念已碎
执念已碎 2020-12-13 08:04

How to get current file name, function name and line number?

I want to use it for logging/debugging purpose, equivalent to __FILE__, __LINE__

8条回答
  •  情话喂你
    2020-12-13 08:29

    I know it's been already a long time, but what I did is __filename.split('\\').pop(). This will get the full path with the filename, split it by \ then get the last index which will be your filename.

提交回复
热议问题