I understood the solution this way:
1- I created a LoggerService .
2- I imported the service into app.module.ts and used it as a provider.
3- LoggerService looks something like this:
import { Injectable } from '@angular/core'; @Injectable() export class LoggerService { public error(message) { try { throw new Error(); } catch (e) { console.log(e.stack); const stackTraces = e.stack.split('at'); const fileList = stackTraces[2].substr( stackTraces[2].lastIndexOf('/src'), stackTraces[2].length - 1 ).replace(')', '' ); const functionName = stackTraces[2].substr(0, stackTraces[2].indexOf('(') - 1);
Roham tehrani
source share