0
0
mirror of https://github.com/honojs/hono.git synced 2024-11-21 18:18:57 +01:00

fix(logger): removing spaces from logger (#3334)

This commit is contained in:
Marcel Overdijk 2024-08-31 04:13:09 +02:00 committed by GitHub
parent 72f4c9dc2c
commit 6c1942923c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 12 deletions

View File

@ -34,7 +34,7 @@ describe('Logger by Middleware', () => {
const res = await app.request('http://localhost/empty')
expect(res).not.toBeNull()
expect(res.status).toBe(200)
expect(log.startsWith(' --> GET /empty \x1b[32m200\x1b[0m')).toBe(true)
expect(log.startsWith('--> GET /empty \x1b[32m200\x1b[0m')).toBe(true)
expect(log).toMatch(/m?s$/)
})
@ -42,7 +42,7 @@ describe('Logger by Middleware', () => {
const res = await app.request('http://localhost/short')
expect(res).not.toBeNull()
expect(res.status).toBe(200)
expect(log.startsWith(' --> GET /short \x1b[32m200\x1b[0m')).toBe(true)
expect(log.startsWith('--> GET /short \x1b[32m200\x1b[0m')).toBe(true)
expect(log).toMatch(/m?s$/)
})
@ -50,7 +50,7 @@ describe('Logger by Middleware', () => {
const res = await app.request('http://localhost/long')
expect(res).not.toBeNull()
expect(res.status).toBe(200)
expect(log.startsWith(' --> GET /long \x1b[32m200\x1b[0m')).toBe(true)
expect(log.startsWith('--> GET /long \x1b[32m200\x1b[0m')).toBe(true)
expect(log).toMatch(/m?s$/)
})
@ -58,7 +58,7 @@ describe('Logger by Middleware', () => {
const res = await app.request('http://localhost/seconds')
expect(res).not.toBeNull()
expect(res.status).toBe(200)
expect(log.startsWith(' --> GET /seconds \x1b[32m200\x1b[0m')).toBe(true)
expect(log.startsWith('--> GET /seconds \x1b[32m200\x1b[0m')).toBe(true)
expect(log).toMatch(/1s/)
})
@ -70,7 +70,7 @@ describe('Logger by Middleware', () => {
const res = await app.request('http://localhost/notfound')
expect(res).not.toBeNull()
expect(res.status).toBe(404)
expect(log.startsWith(' --> GET /notfound \x1b[33m404\x1b[0m')).toBe(true)
expect(log.startsWith('--> GET /notfound \x1b[33m404\x1b[0m')).toBe(true)
expect(log).toMatch(/m?s$/)
})
})
@ -111,7 +111,7 @@ describe('Logger by Middleware in NO_COLOR', () => {
const res = await app.request('http://localhost/empty')
expect(res).not.toBeNull()
expect(res.status).toBe(200)
expect(log.startsWith(' --> GET /empty 200')).toBe(true)
expect(log.startsWith('--> GET /empty 200')).toBe(true)
expect(log).toMatch(/m?s$/)
})
@ -119,7 +119,7 @@ describe('Logger by Middleware in NO_COLOR', () => {
const res = await app.request('http://localhost/short')
expect(res).not.toBeNull()
expect(res.status).toBe(200)
expect(log.startsWith(' --> GET /short 200')).toBe(true)
expect(log.startsWith('--> GET /short 200')).toBe(true)
expect(log).toMatch(/m?s$/)
})
@ -127,7 +127,7 @@ describe('Logger by Middleware in NO_COLOR', () => {
const res = await app.request('http://localhost/long')
expect(res).not.toBeNull()
expect(res.status).toBe(200)
expect(log.startsWith(' --> GET /long 200')).toBe(true)
expect(log.startsWith('--> GET /long 200')).toBe(true)
expect(log).toMatch(/m?s$/)
})
@ -135,7 +135,7 @@ describe('Logger by Middleware in NO_COLOR', () => {
const res = await app.request('http://localhost/seconds')
expect(res).not.toBeNull()
expect(res.status).toBe(200)
expect(log.startsWith(' --> GET /seconds 200')).toBe(true)
expect(log.startsWith('--> GET /seconds 200')).toBe(true)
expect(log).toMatch(/1s/)
})
@ -147,7 +147,7 @@ describe('Logger by Middleware in NO_COLOR', () => {
const res = await app.request('http://localhost/notfound')
expect(res).not.toBeNull()
expect(res.status).toBe(404)
expect(log.startsWith(' --> GET /notfound 404')).toBe(true)
expect(log.startsWith('--> GET /notfound 404')).toBe(true)
expect(log).toMatch(/m?s$/)
})
})

View File

@ -55,8 +55,8 @@ function log(
) {
const out =
prefix === LogPrefix.Incoming
? ` ${prefix} ${method} ${path}`
: ` ${prefix} ${method} ${path} ${colorStatus(status)} ${elapsed}`
? `${prefix} ${method} ${path}`
: `${prefix} ${method} ${path} ${colorStatus(status)} ${elapsed}`
fn(out)
}