Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: incorrect status code shown on log #71

Closed
1 task done
sludgepudge opened this issue Jan 11, 2025 · 2 comments · Fixed by #72
Closed
1 task done

Bug: incorrect status code shown on log #71

sludgepudge opened this issue Jan 11, 2025 · 2 comments · Fixed by #72
Assignees
Labels
bug 🐞 Something isn't working

Comments

@sludgepudge
Copy link

Latest Version Checked

  • I have checked the latest version.

Platform

Linux 🐧

Priority

Low 💤

Screenshots

No response

Description

The logger shows an error 500 whenever `error` is used, no matter what status code is supplied to the method, likewise it will show a status 200 on a get method even when forcibly returning an error.

When testing, I can arbitrarily set any status code I want and whilst my test client (Insomnia in this instance) shows the status code I set, the console logger will always show it as error 500.

Steps to Reproduce

Create an Elysia instance and use the logger with the following options:


.use(logixlysia({
	config: {
		showStartupMessage: true,
		startupMessageFormat: 'banner',
		timestamp: {
			translateTime: 'dd-mm-yyyy HH:MM:ss',
		},
		ip: true,
		customLogFormat: '🦊 {now} {level} {duration} {method} {pathname} {status} {message} {ip}'
	}
}))

Then add a GET method to any path and have it return an error with any status code desired. The logger will always show status 200, even when a client like Insomnia or Postman will show the actual status code.



### Expected Behavior

```Markdown
The status code on the logger to be consistent with the status code being set in the response.

Actual Behavior

As stated above.

Additional Information

No response

Reproduction Repository

No response

@sludgepudge sludgepudge added the bug 🐞 Something isn't working label Jan 11, 2025
@sludgepudge
Copy link
Author

I'm going down a rabbit hole now and discovering that there is far too many ways of triggering incorrect status messages on the logger.

I went so far as to go back to version 3.0.1 where a change was made specifically because of "wrong status code" (#33) and am still seeing the same issue. I guess the real question is 'how does the logger determine what status code to offer on the log line' because it seems completely disconnected from what is actually being set in the response.

@PunGrumpy
Copy link
Owner

Sorry for the slow response, I've been having a lot of fun making my personal website 🥹

I've used StatusMap from Elysia.js. Now supports both numeric status codes (e.g. 429) and status messages (e.g. "Too Many Requests"). Let me know if you need any adjustments.

@PunGrumpy PunGrumpy self-assigned this Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants