Skip to content

Commit d8748c9

Browse files
committed
casync-http: add some traces to debug
The macro log_trace is imported from systemd.
1 parent edb7225 commit d8748c9

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/casync-http.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,8 @@ static int ca_chunk_downloader_step(CaChunkDownloader *dl) {
788788
r = ca_chunk_downloader_process_curl_multi(dl);
789789
if (r < 0)
790790
return log_error_errno(r, "Failed while processing curl multi: %m");
791+
if (r > 0)
792+
log_trace("Processed %d curl messages", r);
791793

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

808812
/* Get as many chunk requests as we can */
809813
r = ca_chunk_downloader_fetch_chunk_requests(dl);
810814
if (r == -EPIPE)
811815
return r;
812816
if (r < 0)
813817
return log_error_errno(r, "Failed while querying remote for chunk requests: %m");
818+
if (r > 0)
819+
log_trace("Fetched %d chunk requests from remote", r);
814820

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

870+
log_trace("SLEEP - handles: added=%" PRIu64 ", rem=%" PRIu64 " - chunks: put=%" PRIu64,
871+
dl->inprogress->n_added, dl->inprogress->n_removed, dl->completed->n_removed);
872+
864873
c = curl_multi_wait(dl->multi, waitfds, ELEMENTSOF(waitfds), curl_timeout_ms, &n);
865874
if (c != CURLM_OK)
866875
return log_error_curlm(c, "Failed to wait with curl multi");
867876

877+
log_trace("AWAKEN - %d event(s)", n);
878+
868879
return 0;
869880
}
870881

src/log.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,9 @@ static inline int log_oom(void) {
3939

4040
void set_log_level(int level);
4141
int set_log_level_from_string(const char *str);
42+
43+
#ifdef LOG_TRACE
44+
# define log_trace(...) log_debug(__VA_ARGS__)
45+
#else
46+
# define log_trace(...) do {} while (0)
47+
#endif

0 commit comments

Comments
 (0)