Писал на вскидку, могут быть косяки, не судите строго
"use strict";
var test={
blabla:function(){
console.log(fullTrace()[1].funcName);
},
blabla1:function(){
console.log(fullTrace()[1].funcName);
},
blabla2:function(){
console.log(JSON.stringify(fullTrace(), null, 4));
}
};
(function start(){
test.blabla();
test.blabla1();
test.blabla2();
})();
function fullTrace(){
let stack;
try{ throw Exception() }
catch(e) { stack = e.stack.split(/\n/g); }
/* exp msg */ stack.shift();
return stack.map(s => {
let row = s.replace(/^\s*at\s+/,''), m;
if(m = row.match(/([^\s\(]+) \(([^:]+):(\d+):(\d+)\)/))
return {funcName:m[1],filePath:m[2],strNum:m[3],colNum:m[4]}
else if(m = row.match(/([^:]+):(\d+):(\d+)/))
return {filePath:m[1],strNum:m[2],colNum:m[3]}
} )
}
выведет
Object.blabla
Object.blabla1
[
{
"funcName": "fullTrace",
"filePath": "<anonymous>",
"strNum": "22",
"colNum": "10"
},
{
"funcName": "Object.blabla2",
"filePath": "<anonymous>",
"strNum": "10",
"colNum": "32"
},
{
"funcName": "start",
"filePath": "<anonymous>",
"strNum": "17",
"colNum": "10"
},
{
"filePath": "<anonymous>",
"strNum": "18",
"colNum": "3"
}
]