Overwrite chrome console log location with custom logging

Viewed 154

When you use console.log('hi') in chrome it prints out the location of where the log came from. The problem I have is that I am intercepting the console log right now in chrome like this.

this.originalConsoleLog = console.log;

console.log = this.log.bind(this);

function log(message?: any, ...optionalParams: any[]): void {
  this.originalConsoleLog(message, optionalParams);
  this.splunkLogger('LOG', message, optionalParams);
}

So in chrome anything that I log now will come from this location which is REALLY annoying trying to figure out where my problems are coming from now.

Here is an example: enter image description here

I want that to not say logger.service.ts:36, and instead say desktop.ts:24, or funtime.ts:69 it is not at all helpful in its current form. Maybe if I call it with this.originalConsoleLog(arguments); it will ignore my logging function?

0 Answers
Related