Skip to content

Instantly share code, notes, and snippets.

@victor141516
Created July 11, 2025 13:37
Show Gist options
  • Save victor141516/5a60cd83b455ba9610f7bd02097aa439 to your computer and use it in GitHub Desktop.
Save victor141516/5a60cd83b455ba9610f7bd02097aa439 to your computer and use it in GitHub Desktop.
function getLogger(prefix: string, time = false): Console {
return new Proxy(console, {
get(target, prop) {
if (typeof target[prop] === 'function') {
return function(...args) {
return target[prop](`[${prefix} ${time ? new Date().toISOString() : ''}]`, ...args);
};
}
return target[prop];
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment