Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/middleware/logger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ enum LogPrefix {
Error = 'xxx',
}

const humanize = (times: string[]) => {
const humanize = (times: string[]): string => {
const [delimiter, separator] = [',', '.']

const orderTimes = times.map((v) => v.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1' + delimiter))

return orderTimes.join(separator)
}

const time = (start: number) => {
const time = (start: number): string => {
const delta = Date.now() - start
return humanize([delta < 1000 ? delta + 'ms' : Math.round(delta / 1000) + 's'])
}

const colorStatus = async (status: number) => {
const colorStatus = async (status: number): Promise<string> => {
const colorEnabled = await getColorEnabledAsync()
if (colorEnabled) {
switch ((status / 100) | 0) {
Expand Down Expand Up @@ -54,7 +54,7 @@ async function log(
path: string,
status: number = 0,
elapsed?: string
) {
): Promise<void> {
const out =
prefix === LogPrefix.Incoming
? `${prefix} ${method} ${path}`
Expand Down