Skip to content

Commit

Permalink
fix: log prefix (closes #129)
Browse files Browse the repository at this point in the history
  • Loading branch information
qq15725 committed Feb 13, 2025
1 parent 810cce6 commit e8b2d3f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/create-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ export interface Logger {
warn: (...args: any[]) => void
}

let uid = 0
export function createLogger(debug: boolean): Logger {
const prefix = `${PREFIX}[#${uid}]`
uid++
return {
// eslint-disable-next-line no-console
time: (label: string) => debug && console.time(`${PREFIX} ${label}`),
time: (label: string) => debug && console.time(`${prefix} ${label}`),
// eslint-disable-next-line no-console
timeEnd: (label: string) => debug && console.timeEnd(`${PREFIX} ${label}`),
timeEnd: (label: string) => debug && console.timeEnd(`${prefix} ${label}`),
warn: (...args: any[]) => debug && consoleWarn(...args),
}
}

0 comments on commit e8b2d3f

Please sign in to comment.