Skip to content

Commit

Permalink
perf: use Intl.DateTimeFormatter instead of toLocaleTimeString (#13951)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev authored Jul 25, 2023
1 parent 6251a66 commit af53a1d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/vite/src/node/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ export function createLogger(
return options.customLogger
}

const timeFormatter = new Intl.DateTimeFormat(undefined, {
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
})
const loggedErrors = new WeakSet<Error | RollupError>()
const { prefix = '[vite]', allowClearScreen = true } = options
const thresh = LogLevels[level]
Expand All @@ -77,7 +82,7 @@ export function createLogger(
: type === 'warn'
? colors.yellow(colors.bold(prefix))
: colors.red(colors.bold(prefix))
return `${colors.dim(new Date().toLocaleTimeString())} ${tag} ${msg}`
return `${colors.dim(timeFormatter.format(new Date()))} ${tag} ${msg}`
} else {
return msg
}
Expand Down

0 comments on commit af53a1d

Please sign in to comment.