Implementing a custom logger service for Angular 17. Now I want to keep track of the line number of where the service has been called.
Here is my code for retrieving the caller inside the service:
const stack = new Error().stack;
const stackArray = stack?.split('n') || [];
const callerLine: string = stackArray[3].trim();
When I now console.log(stack)
the output contains the typescript files with correct line numbers.
But after the .split()
the callerLine string shows the javascript position.
Why is this happening?