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

Support logging request/socket information in custom Logger.log function #761

Open
mortenson opened this issue Dec 17, 2023 · 1 comment
Assignees

Comments

@mortenson
Copy link

The problem I am facing
When using a custom Logger.log function, all you get passed to you is the message as a string. It'd be nice if you were also passed as much information about the current socket/request as possible, so that you could log the client IP address, user agent, and other information common in more traditional HTTP logs.

The solution I would like
Since changing the signature of LoggerConfiguration.log would probably break backwards compatibility, maybe either:

  1. A new LoggerConfiguration property like logFormat, which has more parameters including request/socket information and returns a string. Beyond adding request information, this seems generically useful for doing something like structured logging (JSON instead of having the timestamp in the log message) as well.
  2. More request/socket information passed to hooks - I tried adding logging in onAuthenticate but was not able to determine the request/socket IP address from onAuthenticatePayload.

Alternatives I have considered
Making my own Logger extension, which would be OK but I'm not sure how to get the client IP address in hooks like onAuthenticatePayload.

Additional context
At a high level I'm trying to add enough logging to the hocuspocus to make debugging security incidents feasible, which at a minimum would need the IP address of the current connection (for log messages where that is relevant).

@mortenson
Copy link
Author

Note that if hocuspocus is behind a proxy, requestHeaders is probably sufficient (although you'll still need a completely custom logger, so the logFormat idea I think is still OK).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants