Get the name of the currently executing function in Angular 2 and TypeScript

Viewed 2011

This question is for an Angular 2 application with TypeScript.

I need to log a custom message, the name of the class or component, and the name of the function from where I am logging.

Right now, I am hard-coding those values (again this is TypeScript):

class MyService {
  getUsers() {
    console.log('MyService.getUsers()', 'I am here');
  }

But, I don't want to hardcode the name of the class and function.

I managed to get the name of the class or component:

console.log(MyService.name);

But how can I get the name of the currently executing function?

1 Answers
Related