Logger decorator

Typescript method decorator

Redin Gaetan
1 min readOct 2, 2021


Hey, often we make console.log(...) to see the value of a parameter or a result method.

Here I present you a decorator which allow to do it easily. It’s purpose is for debugging when you are developing something.

Now that’s how to use it:

class Toto {
public myMethod(...args: unknown[]): boolean { ... }
@Log({ outputs: false })
public myMethod2(...args: unknown[]): void { ... }
@Log({ inputs: false })
public myMethod3(...args: unknown[]): unknown { ... }
@Log({ type: 'trace' })
public myMethod4(...args: unknown[]): unknown { ... }
@Log({ type: 'trace', inputs: false, outputs: false })
public myMethod5(...args: unknown[]): unknown { ... }

Hope this could help or inspire someone.

Thanks for reading, feel free to comment.

Learn More