How does js view caller information in strict mode?

problem description

I use the Vue framework to encode, and due to the vue single-file feature, vue encoding automatically changes to strict mode. So I implemented my own platform_errlog in other js, but because I can"t use arguments to view the caller"s operation in strict mode

the environmental background of the problems and what methods you have tried

my errolog.js does not use strict mode. Should I change it to a non-ES6 module output mode, where I can also use require to avoid strict mode? I can"t implement link tracking in my errlog. Do you have a way to solve this problem? Thank you!

related codes

export function errlog(log_info) {
  console.log("========================================");
  console.log("| lg_admin:");
  console.log("| ",log_info);
  console.log("----------------------------------------");
}

export function err_entity_log(info, data) {
  console.log("========================================");
  console.log("| lg_admin:");
  console.log("| ",info);
  console.log("| ",data);
  console.log("----------------------------------------");
}

export function log_entity(info, data) {
  console.log("========================================");
  console.log("| lg_admin_log:");
  console.log("| ",info);
  console.log("| ",data);
  console.log("----------------------------------------");
}

what result do you expect? What is the error message actually seen?

paste the actual error message:

TypeError: "caller", "callee", and "arguments" properties may not be accessed on strict mode functions
Apr.25,2022

I have done similar things, and my solution is:

if your target function is free to modify, you can

try{
    throw new Error("Caller Satck");
}catch(e){
    console.log(e.stack)
}

, if the target function cannot be modified, use a proxy or something like that, proxy it, and do the same thing

my blog get the function call stack in strict mode

Menu