17 lines
506 B
TypeScript
17 lines
506 B
TypeScript
// Replaces console.log with a version that prefixes a timestamp
|
|
function injectConsoleLog() {
|
|
const originalLog = console.log
|
|
|
|
function customLog(message?: any, ...optionalParams: any[]) {
|
|
const now = new Date()
|
|
const timestamp = now.toTimeString().split(' ')[0] // hh:mm:ss
|
|
originalLog(`[${timestamp}] ${message}`, ...optionalParams)
|
|
}
|
|
|
|
console.log = customLog
|
|
return null
|
|
}
|
|
|
|
// Run once at first file import
|
|
export const _inject_run_once = injectConsoleLog()
|