From 610284dcc38461c671598439fc3d3cd059e89f1e Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Mon, 7 Apr 2014 17:45:54 +0200 Subject: [PATCH] sources: log selection messages only in normal reference update mode We don't want to see source selection messages when initstepslew is running. --- sources.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/sources.c b/sources.c index 364058a..a4b67e1 100644 --- a/sources.c +++ b/sources.c @@ -384,6 +384,16 @@ SRC_ResetReachability(SRC_Instance inst) /* ================================================== */ +static void +log_selection_message(char *format, char *arg) +{ + if (REF_GetMode() != REF_ModeNormal) + return; + LOG(LOGS_INFO, LOGF_Sources, format, arg); +} + +/* ================================================== */ + static int compare_sort_elements(const void *a, const void *b) { @@ -528,7 +538,7 @@ SRC_SelectSource(SRC_Instance updated_inst) if (n_sources == 0) { /* In this case, we clearly cannot synchronise to anything */ if (selected_source_index != INVALID_SOURCE) { - LOG(LOGS_INFO, LOGF_Sources, "Can't synchronise: no sources"); + log_selection_message("Can't synchronise: no sources", NULL); selected_source_index = INVALID_SOURCE; REF_SetUnsynchronised(); } @@ -701,7 +711,7 @@ SRC_SelectSource(SRC_Instance updated_inst) */ if (selected_source_index != INVALID_SOURCE) { - LOG(LOGS_INFO, LOGF_Sources, "Can't synchronise: no majority"); + log_selection_message("Can't synchronise: no majority", NULL); } selected_source_index = INVALID_SOURCE; @@ -907,7 +917,7 @@ SRC_SelectSource(SRC_Instance updated_inst) /* We have to elect a new synchronisation source */ selected_source_index = max_score_index; - LOG(LOGS_INFO, LOGF_Sources, "Selected source %s", + log_selection_message("Selected source %s", source_to_string(sources[selected_source_index])); #if 0 @@ -955,7 +965,7 @@ SRC_SelectSource(SRC_Instance updated_inst) } else { if (selected_source_index != INVALID_SOURCE) { - LOG(LOGS_INFO, LOGF_Sources, "Can't synchronise: no selectable sources"); + log_selection_message("Can't synchronise: no selectable sources", NULL); } selected_source_index = INVALID_SOURCE; } @@ -964,7 +974,7 @@ SRC_SelectSource(SRC_Instance updated_inst) } else { /* No sources provided valid endpoints */ if (selected_source_index != INVALID_SOURCE) { - LOG(LOGS_INFO, LOGF_Sources, "Can't synchronise: no reachable sources"); + log_selection_message("Can't synchronise: no reachable sources", NULL); } selected_source_index = INVALID_SOURCE; }