X-Git-Url: https://git.wpitchoune.net/gitweb/?p=prss.git;a=blobdiff_plain;f=src%2Fhttp.c;h=52238ec9ace98c1b97956a450f69bfd2fe4cfa23;hp=43053edbcd7a02deb3a6917e827cb0eab557b5b5;hb=09a826a93753ebb1b82fbc30574c034f084e02b8;hpb=ba998dd7b5a61fc2a1fa25538dc370eff0368c2c diff --git a/src/http.c b/src/http.c index 43053ed..52238ec 100644 --- a/src/http.c +++ b/src/http.c @@ -27,8 +27,7 @@ #include #include "http.h" - -static int debug; +#include "log.h" struct ucontent { char *data; @@ -87,7 +86,7 @@ char *http_get(const char *url, const char *content) return chunk.data; free(chunk.data); - fprintf(stderr, _("HTTP request fail url=%s"), url); + log_err(_("HTTP request fail url=%s"), url); return NULL; } @@ -98,17 +97,19 @@ json_object *http_json_get(const char *url, struct json_object *j) char *out; struct json_object *result; + if (log_level >= LOG_DEBUG) + log_debug("HTTP request= %s", + json_object_to_json_string(j)); + in = json_object_to_json_string(j); out = http_get(url, in); - if (debug) - printf("HTTP request= %s\n", - json_object_to_json_string(j)); - if (out) { result = json_tokener_parse(out); - if (debug) - printf("HTTP reply= %s\n", out); + + if (log_level >= LOG_DEBUG) + log_debug("HTTP reply= %s", out); + free(out); return result; }