Last active
December 22, 2017 10:24
-
-
Save k1r0s/4eb9f7bf4ce20f1867954b60ac84736b to your computer and use it in GitHub Desktop.
log decorator for JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { afterMethod } from "kaop-ts"; | |
| export const Log = afterMethod(meta => { | |
| const methodName = `${meta.target.constructor.name}::${meta.key}`; | |
| console.info(`log-decorator: ${methodName} invoked!`); | |
| console.info(`log-decorator: ${methodName} arguments -> `, meta.args); | |
| console.info(`log-decorator: ${methodName} result -> `, meta.result); | |
| }); | |
| /* | |
| usage | |
| import { Log } from "./log-decorator"; | |
| class DummyServiceOrComponent { | |
| @Log | |
| anyMethod() { | |
| } | |
| } | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment