Skip to content

Instantly share code, notes, and snippets.

@palanisamym14
Created November 26, 2021 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save palanisamym14/6070cd6466bea68fe41ef632f0549474 to your computer and use it in GitHub Desktop.
Save palanisamym14/6070cd6466bea68fe41ef632f0549474 to your computer and use it in GitHub Desktop.
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