JCMais / node-libcurl

libcurl bindings for Node.js
https://npmjs.org/package/node-libcurl
MIT License
660 stars 117 forks source link

More flexible logging #384

Closed addlistener closed 7 months ago

addlistener commented 1 year ago
  1. 'verbose' does not log request body now. We have to use a echo server to debug
  2. is it possible to turn off "*" logs and only keep "<" and ">" logs? The inquiry happens more frequently in headers & data, we want to turn off the ssl & proxy sometimes.
* STATE: INIT => CONNECT handle 0x7f7e12815a08; line 1879 (connection #-5000)
* Uses proxy env variable http_proxy == 'http://127.0.0.1:7890/'
* Added connection 0. The cache now contains 1 members
* STATE: CONNECT => RESOLVING handle 0x7f7e12815a08; line 1925 (connection #0)
* family0 == v4, family1 == v6
*   Trying 127.0.0.1:7890...
* STATE: RESOLVING => CONNECTING handle 0x7f7e12815a08; line 2009 (connection #0)
* Connected to (nil) (127.0.0.1) port 7890 (#0)
* STATE: CONNECTING => PROTOCONNECT handle 0x7f7e12815a08; line 2074 (connection #0)
* STATE: PROTOCONNECT => DO handle 0x7f7e12815a08; line 2095 (connection #0)
> POST http://localhost:8083/ HTTP/1.1
Host: localhost:8083
User-Agent: node-libcurl/3.0.0
Accept: */*
Proxy-Connection: Keep-Alive
Auth: abc=1
Content-Type: abc
Content-Length: 39
JCMais commented 1 year ago

That is the default log created by libcurl, not something we control on this library, if you need to change the output or forward it somewhere other than stderr, consider setting the DEBUGFUNCTION option. There is an example here: https://github.com/JCMais/node-libcurl/blob/887949944dce38a19ee4ecbc5854aabe757e2a46/examples/12-debug-callback.js