]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemd-analyze: allow --quiet for condition checks
authorRonan Pigott <ronan@rjp.ie>
Wed, 21 Jun 2023 02:47:47 +0000 (19:47 -0700)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 21 Jun 2023 18:56:43 +0000 (19:56 +0100)
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.

src/analyze/analyze-condition.c
src/shared/condition.c

index 6da61cd0cf84c33182f52e875251227178490323..f5d874b9c7cb201881580a56ba4ed8a3ac325484 100644 (file)
@@ -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;
 }
index 9eb49d0eb5f192726d857a4e125453efa7a6a031..a79361e9e181f45d2d6d8d6bf0a6ff33f7c557ad 100644 (file)
@@ -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;