]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: log a recognizable message when a unit succeeds, too
authorLennart Poettering <lennart@poettering.net>
Tue, 13 Nov 2018 22:28:09 +0000 (23:28 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 16 Nov 2018 14:22:48 +0000 (15:22 +0100)
We already are doing it on failure, let's do it on success, too.

Fixes: #10265
12 files changed:
catalog/systemd.catalog.in
src/core/automount.c
src/core/mount.c
src/core/path.c
src/core/scope.c
src/core/service.c
src/core/socket.c
src/core/swap.c
src/core/timer.c
src/core/unit.c
src/core/unit.h
src/systemd/sd-messages.h

index c99da0a634c0fab72198d52285cddf30b9cd680e..5c6799ee5d9a8c08ece25385d99bcec787888d61 100644 (file)
@@ -352,6 +352,13 @@ Support: %SUPPORT_URL%
 
 The unit @UNIT@ completed and consumed the indicated resources.
 
+-- 7ad2d189f7e94e70a38c781354912448
+Subject: Unit succeeded
+Defined-By: systemd
+Support: %SUPPORT_URL%
+
+The unit @UNIT@ has successfully entered the 'dead' state.
+
 -- d9b373ed55a64feb8242e02dbe79a49c
 Subject: Unit failed
 Defined-By: systemd
index 57e6a985fd0486005108a881608748164e32ea5c..9da3f87fca8b843ebd346495bd992d31a7e8f8fa 100644 (file)
@@ -315,7 +315,9 @@ static void automount_enter_dead(Automount *a, AutomountResult f) {
         if (a->result == AUTOMOUNT_SUCCESS)
                 a->result = f;
 
-        if (a->result != AUTOMOUNT_SUCCESS)
+        if (a->result == AUTOMOUNT_SUCCESS)
+                unit_log_success(UNIT(a));
+        else
                 unit_log_failure(UNIT(a), automount_result_to_string(a->result));
 
         automount_set_state(a, a->result != AUTOMOUNT_SUCCESS ? AUTOMOUNT_FAILED : AUTOMOUNT_DEAD);
index 002127bf10800a5cf659c78259f1614a5cb315f0..8035a73184d618d5c78e08df47f36a8fde3b0a12 100644 (file)
@@ -799,7 +799,9 @@ static void mount_enter_dead(Mount *m, MountResult f) {
         if (m->result == MOUNT_SUCCESS)
                 m->result = f;
 
-        if (m->result != MOUNT_SUCCESS)
+        if (m->result == MOUNT_SUCCESS)
+                unit_log_success(UNIT(m));
+        else
                 unit_log_failure(UNIT(m), mount_result_to_string(m->result));
 
         mount_set_state(m, m->result != MOUNT_SUCCESS ? MOUNT_FAILED : MOUNT_DEAD);
index a134fc288c45cc38798daa1069c0f28eabebcc1b..7523bf54f781bec32796e3d4dff90cdc5cae3579 100644 (file)
@@ -449,7 +449,9 @@ static void path_enter_dead(Path *p, PathResult f) {
         if (p->result == PATH_SUCCESS)
                 p->result = f;
 
-        if (p->result != PATH_SUCCESS)
+        if (p->result == PATH_SUCCESS)
+                unit_log_success(UNIT(p));
+        else
                 unit_log_failure(UNIT(p), path_result_to_string(p->result));
 
         path_set_state(p, p->result != PATH_SUCCESS ? PATH_FAILED : PATH_DEAD);
index 9ff082df3aaa166b497591713dab1176d55c3619..6d8d4af56d2b1707b0c7a9dac1be0a5c69b65eac 100644 (file)
@@ -240,7 +240,9 @@ static void scope_enter_dead(Scope *s, ScopeResult f) {
         if (s->result == SCOPE_SUCCESS)
                 s->result = f;
 
-        if (s->result != SCOPE_SUCCESS)
+        if (s->result == SCOPE_SUCCESS)
+                unit_log_success(UNIT(s));
+        else
                 unit_log_failure(UNIT(s), scope_result_to_string(s->result));
 
         scope_set_state(s, s->result != SCOPE_SUCCESS ? SCOPE_FAILED : SCOPE_DEAD);
index 49a1131c384a2c57db9bcbc47733949501791062..a90711213c1ab9bbef6fd51b350ecaf57168aac4 100644 (file)
@@ -1699,7 +1699,9 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart)
         if (s->result == SERVICE_SUCCESS)
                 s->result = f;
 
-        if (s->result != SERVICE_SUCCESS)
+        if (s->result == SERVICE_SUCCESS)
+                unit_log_success(UNIT(s));
+        else
                 unit_log_failure(UNIT(s), service_result_to_string(s->result));
 
         if (allow_restart && service_shall_restart(s))
index de1a558023d070f1b91d7588b69789b124b0ae52..f725c9eb009cdf7428722c3c6596bf352f086eef 100644 (file)
@@ -1985,7 +1985,9 @@ static void socket_enter_dead(Socket *s, SocketResult f) {
         if (s->result == SOCKET_SUCCESS)
                 s->result = f;
 
-        if (s->result != SOCKET_SUCCESS)
+        if (s->result == SOCKET_SUCCESS)
+                unit_log_success(UNIT(s));
+        else
                 unit_log_failure(UNIT(s), socket_result_to_string(s->result));
 
         socket_set_state(s, s->result != SOCKET_SUCCESS ? SOCKET_FAILED : SOCKET_DEAD);
index 40517f2aadd0d16bad1b17609618e51c8fae5ce6..e2b888ec9eab332d588c1b092288866a7cd27777 100644 (file)
@@ -653,7 +653,9 @@ static void swap_enter_dead(Swap *s, SwapResult f) {
         if (s->result == SWAP_SUCCESS)
                 s->result = f;
 
-        if (s->result != SWAP_SUCCESS)
+        if (s->result == SWAP_SUCCESS)
+                unit_log_success(UNIT(s));
+        else
                 unit_log_failure(UNIT(s), swap_result_to_string(s->result));
 
         swap_set_state(s, s->result != SWAP_SUCCESS ? SWAP_FAILED : SWAP_DEAD);
index 98ba868bb106a79e64c21f9915a0065eadfc82e2..c7f769dbe1555b12b794d4a150564e829eeca4fa 100644 (file)
@@ -288,7 +288,9 @@ static void timer_enter_dead(Timer *t, TimerResult f) {
         if (t->result == TIMER_SUCCESS)
                 t->result = f;
 
-        if (t->result != TIMER_SUCCESS)
+        if (t->result == TIMER_SUCCESS)
+                unit_log_success(UNIT(t));
+        else
                 unit_log_failure(UNIT(t), timer_result_to_string(t->result));
 
         timer_set_state(t, t->result != TIMER_SUCCESS ? TIMER_FAILED : TIMER_DEAD);
index 54a1bd963cf2ab2904eceb35341582eb81a66ac9..c4d55dc2d3b84f46bcdaf25ee169c13603d9b90f 100644 (file)
@@ -5444,6 +5444,16 @@ int unit_pid_attachable(Unit *u, pid_t pid, sd_bus_error *error) {
         return 0;
 }
 
+void unit_log_success(Unit *u) {
+        assert(u);
+
+        log_struct(LOG_INFO,
+                   "MESSAGE_ID=" SD_MESSAGE_UNIT_SUCCESS_STR,
+                   LOG_UNIT_ID(u),
+                   LOG_UNIT_INVOCATION_ID(u),
+                   LOG_UNIT_MESSAGE(u, "Succeeded."));
+}
+
 void unit_log_failure(Unit *u, const char *result) {
         assert(u);
         assert(result);
index da4843851931925aac950a8e10ed360d6127bb2c..3931684a56428cfa72b63c452f436713ce0c93a4 100644 (file)
@@ -806,6 +806,7 @@ const char *unit_label_path(Unit *u);
 
 int unit_pid_attachable(Unit *unit, pid_t pid, sd_bus_error *error);
 
+void unit_log_success(Unit *u);
 void unit_log_failure(Unit *u, const char *result);
 void unit_log_process_exit(Unit *u, int level, const char *kind, const char *command, int code, int status);
 
index 9ac263c89f62918973ec961a1fc4754fadc0cbc4..293db8e8e1c64bc57996ca3c45d26622437926c0 100644 (file)
@@ -106,6 +106,8 @@ _SD_BEGIN_DECLARATIONS;
 #define SD_MESSAGE_UNIT_RESOURCES         SD_ID128_MAKE(ae,8f,7b,86,6b,03,47,b9,af,31,fe,1c,80,b1,27,c0)
 #define SD_MESSAGE_UNIT_RESOURCES_STR     SD_ID128_MAKE_STR(ae,8f,7b,86,6b,03,47,b9,af,31,fe,1c,80,b1,27,c0)
 
+#define SD_MESSAGE_UNIT_SUCCESS           SD_ID128_MAKE(7a,d2,d1,89,f7,e9,4e,70,a3,8c,78,13,54,91,24,48)
+#define SD_MESSAGE_UNIT_SUCCESS_STR       SD_ID128_MAKE_STR(7a,d2,d1,89,f7,e9,4e,70,a3,8c,78,13,54,91,24,48)
 #define SD_MESSAGE_UNIT_FAILURE_RESULT    SD_ID128_MAKE(d9,b3,73,ed,55,a6,4f,eb,82,42,e0,2d,be,79,a4,9c)
 #define SD_MESSAGE_UNIT_FAILURE_RESULT_STR \
                                           SD_ID128_MAKE_STR(d9,b3,73,ed,55,a6,4f,eb,82,42,e0,2d,be,79,a4,9c)