Is it possible to filter debug data function text? I want to display commands at one time and full output at the other (I want for example to filter out Adding handle: send: 0
). All the time I get a lot of messages. I want something nice like Filezilla Short messages .
Here is my code for debug function and below it a message. I have verbose enabled
int Uploader::DebugDataCallBack(CURL* handle, curl_infotype infotype, char* msg, size_t size, void* f)
{
int level= 1; //debug info 0-None, 1-necessary 2 - All TODO: Should come from config
switch(level) //error level
{
case 0:
{
break; //do nothing
}
case 1:
{
//only necessary, skip headers
if(infotype==CURLINFO_TEXT)
{
static_cast<Uploader*>(f)->SendMessage(wxString(msg));
}
}
default:
{
//full debug messages
static_cast<Uploader*>(f)->SendMessage(wxString(msg));
}
}
return 0;//must return 0
}
----------Thu Dec 26 14:14:40 2013----------
STATE: INIT => CONNECT handle 0x7fffd0001a08; line 998 (connection #-5000)
[14:14:40]
STATE: INIT => CONNECT handle 0x7fffd0001a08; line 998 (connection #-5000)
[14:14:40]
Rebuilt URL to: ftp://ftp.mysite.com/
[14:14:40]
Rebuilt URL to: ftp://ftp.mysite.com/
[14:14:40]
About to connect() to ftp.mysite.com port 21 (#0)
[14:14:40]
About to connect() to ftp.mysite.com port 21 (#0)
[14:14:40]
Trying 31.170.162.203...
[14:14:40]
Trying 31.170.162.203...
[14:14:40]
Adding handle: conn: 0x7fffd0013b48
[14:14:40]
Adding handle: conn: 0x7fffd0013b48
[14:14:40]
Adding handle: send: 0
[14:14:40]
Adding handle: send: 0
[14:14:40]
Adding handle: recv: 0
[14:14:40]
Adding handle: recv: 0
[14:14:40]
Curl_addHandleToPipeline: length: 1
[14:14:40]
Curl_addHandleToPipeline: length: 1
[14:14:40]
0x7fffd0001a08 is at send pipe head!
[14:14:40]
0x7fffd0001a08 is at send pipe head!
[14:14:40]
- Conn 0 (0x7fffd0013b48) send_pipe: 1, recv_pipe: 0
[14:14:40]
- Conn 0 (0x7fffd0013b48) send_pipe: 1, recv_pipe: 0
[14:14:40]
STATE: CONNECT => WAITCONNECT handle 0x7fffd0001a08; line 1045 (connection #0)
[14:14:40]
STATE: CONNECT => WAITCONNECT handle 0x7fffd0001a08; line 1045 (connection #0)
[14:14:40]
Connected to ftp.mysite.com (31.170.162.203) port 21 (#0)
[14:14:40]
Connected to ftp.mysite.com (31.170.162.203) port 21 (#0)
[14:14:40]
FTP 0x7fffd0013fe0 (line 3174) state change from STOP to WAIT220
[14:14:40]
FTP 0x7fffd0013fe0 (line 3174) state change from STOP to WAIT220
[14:14:40]
STATE: WAITCONNECT => PROTOCONNECT handle 0x7fffd0001a08; line 1158 (connection #0)
[14:14:40]
STATE: WAITCONNECT => PROTOCONNECT handle 0x7fffd0001a08; line 1158 (connection #0)
[14:14:40]
First Enable curl by putting verbose to 1L that is CURLOPT_VERBOSE in curl_easy_setopt. Theb set the debug function, that is CURLOPT_DEBUGFUNCTION to receive the debug messages. Then use codes infotypes to filter out what you want. If you want to get command/response like I wanted just take message from Header in/out. Here is piece of code just to show it!
switch(infotype)
{
case CURLINFO_HEADER_OUT:
{
wxString message = _("COMMAND: ")+wxString(msg);
SendMessage(message);
break;
}
case CURLINFO_HEADER_IN:
{
wxString message = _("RESPONSE: ")+wxString(msg);
SendMessage(message);
break;
}
}