Created
May 13, 2023 12:53
-
-
Save christopherbauer/ff684ff438ec2ec174079e2131c8415c to your computer and use it in GitHub Desktop.
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 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