fix(logger): removing spaces from logger (#3334)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Marcel Overdijk · committed by GitHub · parent 72f4c9d · Browse files · 2 files·+12 added−12 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+12 added−12 removed
- tests:+10 added−10 removed
- other:+2 added−2 removed
Provenance
- Commit
6c19429- Tree
553b4d6- Author
Marcel Overdijk <marceloverdijk@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
72f4c9d
2 files changed+12 added−12 removed
modified:src/middleware/logger/index.test.ts+10 added-10 removed
32 unmodified lines333435363737383940414243444545464748495051525353545556575859606161626364653 unmodified lines6970717273737475767732 unmodified lines1101111121131141141151161171181191201211221221231241251261271281291301301311321331341351361371381381391401411423 unmodified lines14614714814915015015115215332 unmodified lines it('Log status 200 with empty body', async () => { 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$/) })
it('Log status 200 with small body', async () => { 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$/) })
it('Log status 200 with big body', async () => { 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$/) })
it('Time in seconds', async () => { 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/) })
it('Log status 404', async () => {3 unmodified lines }) 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$/) })})
32 unmodified lines it('Log status 200 with empty body', async () => { 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$/) })
it('Log status 200 with small body', async () => { 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$/) })
it('Log status 200 with big body', async () => { 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$/) })
it('Time in seconds', async () => { 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/) })
it('Log status 404', async () => {3 unmodified lines }) 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$/) })})modified:src/middleware/logger/index.ts+2 added-2 removed
53 unmodified lines54 elapsed?: string55 ) {56 const out =57 prefix === LogPrefix.Incoming58- ? ` ${prefix} ${method} ${path}`59- : ` ${prefix} ${method} ${path} ${colorStatus(status)} ${elapsed}`58+ ? `${prefix} ${method} ${path}`59+ : `${prefix} ${method} ${path} ${colorStatus(status)} ${elapsed}`60 fn(out)61 }62 63 /**30 unmodified lines