Revision 5e03b78d mainbox/query.c

View differences:

mainbox/query.c
1 1
#include "query.h"
2 2
#include "event.h"
3 3
#include "util.h"
4
#include "log.h"
4 5
#include <stdlib.h>
5 6
#include <stdio.h>
6 7
#include <string.h>
......
20 21

  
21 22
  error_code = curl_global_init(CURL_GLOBAL_SSL);
22 23
  if (error_code) {
23
    fprintf(stderr, "curl_global_init: %s\n", curl_easy_strerror(error_code));
24
    log_print("ERROR: curl_global_init: %s\n", curl_easy_strerror(error_code));
24 25
    return error_code;
25 26
  }
26 27

  
......
90 91
  error_code = curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &response);
91 92
  if (error_code) goto error;
92 93
  if (response >= 400)
93
    fprintf(stderr, "Error %ld from %s\n", response, url);
94
    log_print("ERROR: response %ld from %s", response, url);
94 95
  else if (response > 200)
95
    fprintf(stderr, "Warning: response %ld from %s\n", response, url);
96
    log_print("WARNING: response %ld from %s", response, url);
96 97

  
97 98
  curl_easy_cleanup(handle);
98 99
  return result;
99 100

  
100 101
error:
101
  fprintf(stderr, "curl: %s\n", curl_easy_strerror(error_code));
102
  fprintf(stderr, "      when authenticating user %08x on tool %d\n",
102
  log_print("ERROR: curl: %s", curl_easy_strerror(error_code));
103
  log_print("ERROR:       when authenticating user %08x on tool %d",
103 104
      user_id, tool_id);
104 105
  curl_easy_cleanup(handle);
105 106
  return 0;
......
205 206
  error_code = curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &response);
206 207
  if (error_code) goto error;
207 208
  if (response >= 400)
208
    fprintf(stderr, "Error %ld from %s\n", response, buf);
209
    log_print("ERROR: response %ld from %s", response, buf);
209 210
  else if (response > 200)
210
    fprintf(stderr, "Warning: response %ld from %s\n", response, buf);
211
    log_print("WARNING: response %ld from %s", response, buf);
211 212

  
212 213
  curl_easy_cleanup(handle);
213 214
  curl_formfree(formpost);
......
217 218
  return response >= 300;
218 219

  
219 220
error:
220
  fprintf(stderr, "curl: %s\n", curl_easy_strerror(error_code));
221
  log_print("ERROR: curl: %s", curl_easy_strerror(error_code));
221 222
  curl_easy_cleanup(handle);
222 223
  curl_formfree(formpost);
223 224
#ifdef DEBUG_EVENT_RESPONSE

Also available in: Unified diff