Skip to content

Instantly share code, notes, and snippets.

@christopherbauer
Created May 13, 2023 12:53
Show Gist options
  • Save christopherbauer/ff684ff438ec2ec174079e2131c8415c to your computer and use it in GitHub Desktop.
Save christopherbauer/ff684ff438ec2ec174079e2131c8415c to your computer and use it in GitHub Desktop.
import logger from "../logger";
export const LogCall = (
originalMethod: Function,
context: ClassMethodDecoratorContext
) => {
const methodName = String(context.name);
function ReplacementMethod(this: any, ...args: any[]) {
logger.info(
`Entered Method ${methodName} with params ${JSON.stringify(
args
)}`
);
const result = originalMethod.call(this, ...args);
logger.info(
`Exited Method ${methodName} with params ${JSON.stringify(
args
)}`
);
return result;
}
return ReplacementMethod;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment