Skip to content

Instantly share code, notes, and snippets.

@k1r0s
Last active December 22, 2017 10:24
Show Gist options
  • Select an option

  • Save k1r0s/4eb9f7bf4ce20f1867954b60ac84736b to your computer and use it in GitHub Desktop.

Select an option

Save k1r0s/4eb9f7bf4ce20f1867954b60ac84736b to your computer and use it in GitHub Desktop.
log decorator for JavaScript
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