From: Ronan Pigott Date: Wed, 21 Jun 2023 02:47:47 +0000 (-0700) Subject: systemd-analyze: allow --quiet for condition checks X-Git-Tag: v254-rc1~153 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f24590df4387114bc2caa027c3e0bc6c573c6e29;p=thirdparty%2Fsystemd.git systemd-analyze: allow --quiet for condition checks I figure these messages are rather unnecessary, so let the user quiet them with the existing --quiet flag if desired. Makes systemd-analyze condition a little more ergonomic in scripts. --- diff --git a/src/analyze/analyze-condition.c b/src/analyze/analyze-condition.c index 6da61cd0cf8..f5d874b9c7c 100644 --- a/src/analyze/analyze-condition.c +++ b/src/analyze/analyze-condition.c @@ -123,13 +123,14 @@ static int verify_conditions(char **lines, RuntimeScope scope, const char *unit, } } - r = condition_test_list(u->asserts, environ, assert_type_to_string, log_helper, u); + condition_test_logger_t logger = arg_quiet ? NULL : log_helper; + r = condition_test_list(u->asserts, environ, assert_type_to_string, logger, u); if (u->asserts) - log_notice("Asserts %s.", r > 0 ? "succeeded" : "failed"); + log_full(arg_quiet ? LOG_DEBUG : LOG_NOTICE, "Asserts %s.", r > 0 ? "succeeded" : "failed"); - q = condition_test_list(u->conditions, environ, condition_type_to_string, log_helper, u); + q = condition_test_list(u->conditions, environ, condition_type_to_string, logger, u); if (u->conditions) - log_notice("Conditions %s.", q > 0 ? "succeeded" : "failed"); + log_full(arg_quiet ? LOG_DEBUG : LOG_NOTICE, "Conditions %s.", q > 0 ? "succeeded" : "failed"); return r > 0 && q > 0 ? 0 : -EIO; } diff --git a/src/shared/condition.c b/src/shared/condition.c index 9eb49d0eb5f..a79361e9e18 100644 --- a/src/shared/condition.c +++ b/src/shared/condition.c @@ -1206,8 +1206,6 @@ bool condition_test_list( int triggered = -1; - assert(!!logger == !!to_string); - /* If the condition list is empty, then it is true */ if (!first) return true;