From a95bccef85b9dbf2ff31a27b2621b364d7ed1eca Mon Sep 17 00:00:00 2001 From: exoego Date: Fri, 1 Nov 2024 06:38:39 +0900 Subject: [PATCH] refactor(logger): remove unreachable cases. Response accepts 200-599 --- src/middleware/logger/index.test.ts | 6 ------ src/middleware/logger/index.ts | 10 +++------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/middleware/logger/index.test.ts b/src/middleware/logger/index.test.ts index bb644150b..bde7b6c26 100644 --- a/src/middleware/logger/index.test.ts +++ b/src/middleware/logger/index.test.ts @@ -33,15 +33,9 @@ describe('Logger by Middleware', () => { Location: '/empty', }) }) - app.get('/1xx', (c) => { - return c.text('', 100) - }) app.get('/5xx', (c) => { return c.text('', 511) }) - app.get('/7xx', (c) => { - return c.text('', 777 as never) - }) }) it('Log status 200 with empty body', async () => { diff --git a/src/middleware/logger/index.ts b/src/middleware/logger/index.ts index 614066c09..b602df0d2 100644 --- a/src/middleware/logger/index.ts +++ b/src/middleware/logger/index.ts @@ -32,18 +32,14 @@ const colorStatus = (status: number) => { return `${status}` } switch ((status / 100) | 0) { - case 7: // magenta = ??? - return `\x1b[35m${status}\x1b[0m` case 5: // red = error return `\x1b[31m${status}\x1b[0m` + case 4: // yellow = warning + return `\x1b[33m${status}\x1b[0m` case 3: // cyan = redirect return `\x1b[36m${status}\x1b[0m` - case 2: - case 1: // green = success + case 2: // green = success return `\x1b[32m${status}\x1b[0m` - case 4: - case 0: // yellow = warning - return `\x1b[33m${status}\x1b[0m` } }