From f6ca0791a91b4aab3b5fc00276fb32bdde3c0211 Mon Sep 17 00:00:00 2001 From: Florian Stinglmayr Date: Tue, 9 Jul 2019 14:54:25 +0200 Subject: [PATCH] write debug log to file --- libdc/src/api.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/libdc/src/api.c b/libdc/src/api.c index 6f7dbad..c7b094b 100644 --- a/libdc/src/api.c +++ b/libdc/src/api.c @@ -79,26 +79,27 @@ void dc_api_signal(dc_api_t api, CURL *easy, int code) } } -#ifdef DEBUG -static int debug_callback(CURL *handle, curl_infotype type, - char *data, size_t size, - void *userptr - ) +int debug_callback(CURL *handle, curl_infotype type, + char *data, size_t size, + void *userptr) { + FILE *f = fopen("debug.log", "a+"); + switch (type) { - case CURLINFO_TEXT: printf("+T: %s", data); break; - case CURLINFO_HEADER_IN: printf(">H: %s", data); break; - case CURLINFO_HEADER_OUT: printf("D: %s\n", data); break; - case CURLINFO_DATA_OUT: printf("H: %s", data); break; + case CURLINFO_HEADER_OUT: fprintf(f, "D: %s\n", data); break; + case CURLINFO_DATA_OUT: fprintf(f, "