-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Client logging in case of errors #870
Comments
@miketsts, yes, the current log interface is only for HTTP level information, not TCP/SSL level. If the TCP/SSL level logger is implemented, we have to introduce another log interface for this purpose, but we get two different log streams and hard to tell the actual order of each item in both streams. Another way is to integrate the TCP/SSL error into the current log interface, but it'll break the current interface and make it more complicated. I don't come up with a good solution, yet... What do you know other HTTP server libraries are doing in this regard? Thanks for your help! |
@yhirose, unfortunately, I don't have experience with other libraries, at least on a client side. This is why I chose cpp-httplib, and I am pretty much happy with it :-) When I implemented logging in my application (in another interface, not HTTP), I separated the request and response. In such case it's always clear what has been sent, and what was the response, including errors. |
I actually found my own another older implementation. It is server side processing, but the principle can be the same. |
An additional idea came to my mind. Currently, the user supplied logger callback has two parameters - request and response. We can add an additional parameter: event, which can be an enum having different values, like "start processing", "end processing", etc. The enum can be extended in the future, while the user callback can decide which events it wishes to log, and which it does not. |
@yhirose I understand what you mean. |
Hi @yhirose , I wanted to ask here instead of opening a new issue. Is there currently a built-in logging mechanism that provides information about requests on the client/server side? What kind of mechanism should I set up for this? |
A client calls the logger only in case of successful request completion, no matter the HTTP status is successful or not.
However, in case of an error, for example,
httplib::Read
the logger is not called. As a result, my application log does not contain a log record of a request content.Well, I can of course add this capability to my application logic. But don't you think this could be better addressed in a library, if it in any case supports logging?
To tell the truth, I don't know what is the correct solution, I'm thinking loud ...
The text was updated successfully, but these errors were encountered: