Created
July 11, 2025 13:37
-
-
Save victor141516/5a60cd83b455ba9610f7bd02097aa439 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
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