-
-
Notifications
You must be signed in to change notification settings - Fork 957
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
Log HTTP client behaviour #559
Comments
I agree this would be useful. I think |
I have refactored Roarr into two packages: Now Roarr logger package is 304K. Now the bulk of the size comes from If the intent is to compete with other packages on package size, then this is going to compromise your position.
This approach works great for applications, but it sucks for modules. I explain the distinction in https://github.com/gajus/roarr#motivation. tl;dr; When you have an application which depends on modules that use got, there is no way to enable got logging without digging through node_modules/ and patching the code.
I like |
Environment variable? Alternatively or in addition to, we could have a singleton emitter, that logs for all instances, so you could just |
Not if you go with the custom event approach. Environment variables can only toggle logging, not configure the hooks. debug (module) and
Unfortunately, you cannot do that either, because the application will loose access to the singleton if modules depend on incompatible Got versions. This is the reason why Roarr is using |
I was responding to the comment about the problem of not being able to toggle it.
Got could use |
If you use a Symbol, then you are back to square one – Symbols are not going to be shared between incompatible Got versions. Of course, you could create a dedicated package just for the symbol... thats a bit of stretch. In general, yes, this approach would work. I am not recommending it as it is effectively inlining logger logic into the package, but it does the job. |
Right, good point. |
@gajus would you mind taking a look at #561 (WIP)? I think it would facilitate the introspection features you're describing. I'm looking for feedback on the interface and mechanics, so feel free to add your perspective. Notably, cache hit/miss is not facilitated. I need to look again, but I think those have to be inferred by 'response' without 'request' (for a hit) and 'request' (for a miss). |
I think it's important that the software directly consuming
whatever goes on in |
I argue for the exact opposite. Logging (not to confuse with debugging) serves the purpose of exposing all available information about application to enable a comprehensive view of all attributes associated with the application. One of these attributes is HTTP requests. Therefore, if I enable HTTP logging for an application, I expect a comprehensive view of all requests made either by my application or descendent components. What is the logic for what you are arguing? |
With an allowance for redaction of sensitive information, I agree. The issue is the "if I enable" part. I'm saying settings made in or for a descendant or sibling component should not affect what I have here. |
Thats a responsibility of the log consumer, not the application. Something like Logstash would be responsible for stripping away the data that is not supposed to leave enter the log database, e.g. passwords and such. This is a manual process and a responsibility of your sysops. |
I might agree, but that's making a lot of assumptions about the stack. How many users of |
There are a lot bigger security concerns prior to concerning with log neutralisation. |
@gajus You can achieve what you want using custom instances. I'd use |
Thats what we are doing already. The point was to have logging that would enable inspection of all application traffic, including its dependencies. |
Oh.
IMO logging stands for saving data which are useful to improve user's experience. In most cases debugging means using a debugger. The name says that for itself: de-bug, getting rid of bugs.
It can be done in both ways. It's just a matter of choice, some people are comfortable with different ways.
It can be a dev dependency :) There are many ways to implement logging. I don't know which way is better, because I only log the URLs of failed requests, so I can't say much. This issue needs more attention. |
Relevant Node.js thread: nodejs/node#21888 Please comment your use-cases and needs there. |
To begin with, it would be handy to be able to inspect configuration of every HTTP request. I currently do that by wrapping
got
in a helper function that logs whatever the configuration was used to create a request.Other things that would be useful to log:
If you used something like https://github.com/gajus/roarr, there would be near-0 performance impact (calling noop function) when logging is disabled. Logging can be controlled using environment variables.
Happy to contribute an integration.
The text was updated successfully, but these errors were encountered: