Skip to content

Commit af53a1d

Browse files
authoredJul 25, 2023
perf: use Intl.DateTimeFormatter instead of toLocaleTimeString (#13951)
1 parent 6251a66 commit af53a1d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎packages/vite/src/node/logger.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ export function createLogger(
5959
return options.customLogger
6060
}
6161

62+
const timeFormatter = new Intl.DateTimeFormat(undefined, {
63+
hour: 'numeric',
64+
minute: 'numeric',
65+
second: 'numeric',
66+
})
6267
const loggedErrors = new WeakSet<Error | RollupError>()
6368
const { prefix = '[vite]', allowClearScreen = true } = options
6469
const thresh = LogLevels[level]
@@ -77,7 +82,7 @@ export function createLogger(
7782
: type === 'warn'
7883
? colors.yellow(colors.bold(prefix))
7984
: colors.red(colors.bold(prefix))
80-
return `${colors.dim(new Date().toLocaleTimeString())} ${tag} ${msg}`
85+
return `${colors.dim(timeFormatter.format(new Date()))} ${tag} ${msg}`
8186
} else {
8287
return msg
8388
}

0 commit comments

Comments
 (0)
Please sign in to comment.