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

Ability to use auto-logging with requests separate from responses #33

Open
EvHaus opened this issue Feb 27, 2025 · 0 comments
Open

Ability to use auto-logging with requests separate from responses #33

EvHaus opened this issue Feb 27, 2025 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@EvHaus
Copy link

EvHaus commented Feb 27, 2025

What is the problem this feature would solve?

I'd really like to be able to use the autoLogging feature, but I want separate log entries for requests vs. responses (ie. I'd like to log onRequest and a separate log onAfterResponse).

What is the feature you are proposing to solve the problem?

Why? Bun still has some bugs which cause my app to crash or go into infinite loops from time-to-time. This means no log is recorded at to capture what request was made to cause the crash since onAfterResponse never has a chance to fire. Having a separate log created onRequest would ensure I can reliably track down which request caused the problem.

Perhaps an option like:

logger({
  autoLogging: true,
  autoLoggingPlacement: ['onAfterResponse'], // This would be the default (current behaviour)
  autoLoggingPlacement: ['onRequest', 'onAfterResponse'] // This is what I would use
})

What alternatives have you considered?

I understand that I can accomplish this myself by turning off autoLogging and adding the ctx.log.*() calls manually myself, but it would be nice if elysia-logger support this behaviour out-of-the-box.

@EvHaus EvHaus added the enhancement New feature or request label Feb 27, 2025
@bogeychan bogeychan self-assigned this Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants