bun-router 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/logger/logger.ts +8 -12
- package/package.json +1 -1
package/lib/logger/logger.ts
CHANGED
@@ -15,19 +15,15 @@ const timestamp = (date: Date) => {
|
|
15
15
|
}
|
16
16
|
|
17
17
|
// append ANSI color escape sequences to a string based on the given HTTP status code.
|
18
|
-
const colorCode = (n: number, text?:
|
18
|
+
const colorCode = (n: number, text?:string): string => {
|
19
19
|
const s = ` [${String(n)}${text ?? ''}] `;
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
if (n <
|
24
|
-
else if (n <
|
25
|
-
else if (n
|
26
|
-
|
27
|
-
else if (n < 500) backgroundColor = 'bgRed';
|
28
|
-
else foregroundColor = 'white';
|
29
|
-
|
30
|
-
return color(foregroundColor, backgroundColor, s).trim();
|
20
|
+
if (n < 100) return color('black', 'bgYellow', s);
|
21
|
+
else if (n >= 100 && n < 200) return color('black', 'bgCyan', s);
|
22
|
+
else if (n >= 200 && n < 300) return color('black', 'bgGreen', s);
|
23
|
+
else if (n >= 300 && n < 400) return color('black', 'bgRed', s);
|
24
|
+
else if (n >= 400 && n < 500) return color('black', 'bgRed', s);
|
25
|
+
else if (n >= 500) return color('white', 'bgRed', s);
|
26
|
+
return color('white', 'bgBlack', `[${s}]`).trim();
|
31
27
|
}
|
32
28
|
|
33
29
|
|
package/package.json
CHANGED