chiark / gitweb /
execute: increase severity of journal connect failure message
authorMichal Schmidt <mschmidt@redhat.com>
Fri, 15 Feb 2013 23:34:12 +0000 (00:34 +0100)
committerMichal Schmidt <mschmidt@redhat.com>
Sat, 16 Feb 2013 00:18:08 +0000 (01:18 +0100)
journald is supposed to work. Failure to connect to its socket implies
losing messages. It should be a very unusual event. Log the failure with
LOG_CRIT.

Just because this unit's stdout/stderr failed to connect to the journal
does not necessarily mean that we shouldn't try to log the failure using
a structured entry, so let's use log_struct_unit.

src/core/execute.c

index d459dfde649182c1368759d8adb29dd131e33abb..b28962a3c342a5073b1b7dc366be7a0a4150d795 100644 (file)
@@ -389,9 +389,12 @@ static int setup_output(const ExecContext *context, int fileno, int socket_fd, c
         case EXEC_OUTPUT_JOURNAL_AND_CONSOLE:
                 r = connect_logger_as(context, o, ident, unit_id, fileno);
                 if (r < 0) {
-                        log_error("Failed to connect std%s of %s to the journal socket: %s",
+                        log_struct_unit(LOG_CRIT, unit_id,
+                                "MESSAGE=Failed to connect std%s of %s to the journal socket: %s",
                                 fileno == STDOUT_FILENO ? "out" : "err",
-                                unit_id, strerror(-r));
+                                unit_id, strerror(-r),
+                                "ERRNO=%d", -r,
+                                NULL);
                         r = open_null_as(O_WRONLY, fileno);
                 }
                 return r;