]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sources: improve debug messages
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 24 Feb 2022 13:48:24 +0000 (14:48 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 2 Mar 2022 11:11:24 +0000 (12:11 +0100)
Print source status as char and print the name instead of index in
combining.

sources.c

index f1589526d4063908c3e2c456ef01e2f378750c0a..d7fc0a689f2ad850724a7d0661bde5e2dc0e0b29 100644 (file)
--- a/sources.c
+++ b/sources.c
@@ -189,6 +189,7 @@ static void slew_sources(struct timespec *raw, struct timespec *cooked, double d
                          double doffset, LCL_ChangeType change_type, void *anything);
 static void add_dispersion(double dispersion, void *anything);
 static char *source_to_string(SRC_Instance inst);
+static char get_status_char(SRC_Status status);
 
 /* ================================================== */
 /* Initialisation function */
@@ -642,9 +643,10 @@ mark_source(SRC_Instance inst, SRC_Status status)
 {
   inst->status = status;
 
-  DEBUG_LOG("%s status=%d options=%x reach=%o/%d updates=%d distant=%d leap=%d vote=%d lo=%f hi=%f",
-            source_to_string(inst), (int)inst->status, (unsigned int)inst->sel_options,
-            (unsigned int)inst->reachability, inst->reachability_size, inst->updates,
+  DEBUG_LOG("%s status=%c options=%x reach=%o/%d updates=%d distant=%d leap=%d vote=%d lo=%f hi=%f",
+            source_to_string(inst), get_status_char(inst->status),
+            (unsigned int)inst->sel_options, (unsigned int)inst->reachability,
+            inst->reachability_size, inst->updates,
             inst->distant, (int)inst->leap, inst->leap_vote,
             inst->sel_info.lo_limit, inst->sel_info.hi_limit);
 }
@@ -723,8 +725,8 @@ combine_sources(int n_sel_sources, struct timespec *ref_time, double *offset,
     offset_weight = 1.0 / sources[index]->sel_info.root_distance;
     frequency_weight = 1.0 / SQUARE(src_frequency_sd);
 
-    DEBUG_LOG("combining index=%d oweight=%e offset=%e osd=%e fweight=%e freq=%e fsd=%e skew=%e",
-              index, offset_weight, src_offset, src_offset_sd,
+    DEBUG_LOG("combining %s oweight=%e offset=%e osd=%e fweight=%e freq=%e fsd=%e skew=%e",
+              source_to_string(sources[index]), offset_weight, src_offset, src_offset_sd,
               frequency_weight, src_frequency, src_frequency_sd, src_skew);
 
     sum_offset_weight += offset_weight;