Skip to content

Commit

Permalink
casync-http: add some traces to debug
Browse files Browse the repository at this point in the history
The macro log_trace is imported from systemd.
  • Loading branch information
gportay committed Jul 4, 2019
1 parent edb7225 commit d8748c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/casync-http.c
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,8 @@ static int ca_chunk_downloader_step(CaChunkDownloader *dl) {
r = ca_chunk_downloader_process_curl_multi(dl);
if (r < 0)
return log_error_errno(r, "Failed while processing curl multi: %m");
if (r > 0)
log_trace("Processed %d curl messages", r);

/* Step around */
r = ca_chunk_downloader_remote_step(dl);
Expand All @@ -804,13 +806,17 @@ static int ca_chunk_downloader_step(CaChunkDownloader *dl) {
return r;
if (r < 0)
return log_error_errno(r, "Failed while putting chunks to remote: %m");
if (r > 0)
log_trace("Put %d chunks to remote", r);

/* Get as many chunk requests as we can */
r = ca_chunk_downloader_fetch_chunk_requests(dl);
if (r == -EPIPE)
return r;
if (r < 0)
return log_error_errno(r, "Failed while querying remote for chunk requests: %m");
if (r > 0)
log_trace("Fetched %d chunk requests from remote", r);

return CA_CHUNK_DOWNLOADER_POLL;
}
Expand Down Expand Up @@ -861,10 +867,15 @@ static int ca_chunk_downloader_wait(CaChunkDownloader *dl) {
if (r < 0)
return log_error_errno(r, "Failed to get remote io: %m");

log_trace("SLEEP - handles: added=%" PRIu64 ", rem=%" PRIu64 " - chunks: put=%" PRIu64,
dl->inprogress->n_added, dl->inprogress->n_removed, dl->completed->n_removed);

c = curl_multi_wait(dl->multi, waitfds, ELEMENTSOF(waitfds), curl_timeout_ms, &n);
if (c != CURLM_OK)
return log_error_curlm(c, "Failed to wait with curl multi");

log_trace("AWAKEN - %d event(s)", n);

return 0;
}

Expand Down
6 changes: 6 additions & 0 deletions src/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@ static inline int log_oom(void) {

void set_log_level(int level);
int set_log_level_from_string(const char *str);

#ifdef LOG_TRACE
# define log_trace(...) log_debug(__VA_ARGS__)
#else
# define log_trace(...) do {} while (0)
#endif

0 comments on commit d8748c9

Please sign in to comment.