Created
November 26, 2021 13:19
-
-
Save palanisamym14/6070cd6466bea68fe41ef632f0549474 to your computer and use it in GitHub Desktop.
This file contains 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
function log(target:any, name:any, descriptor:any) { | |
const original = descriptor.value; | |
if (typeof original === 'function') { | |
descriptor.value = function(...args: any) { | |
console.log("Logged at: " + new Date().toLocaleString()); | |
console.log(args); | |
console.log(name); | |
console.log(target); | |
try { | |
const result = original.apply(this, args); | |
return result; | |
} catch (e) { | |
console.log(`Error: ${e}`); | |
throw e; | |
} | |
} | |
} | |
return descriptor; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment