chiark / gitweb /
journald: log the slice of a process along with each message in _SYSTEMD_SLICE=
[elogind.git] / src / journal / journald-server.c
index 821935c39048bea38e2736909fd1d1a1f46b9a72..709fa8b7d09921eadc246775d13461c963681729 100644 (file)
@@ -638,6 +638,12 @@ static void dispatch_message_real(
                                 IOVEC_SET_STRING(iovec[n++], x);
                         }
 
+                        if (cg_path_get_slice(c, &t) >= 0) {
+                                x = strappenda("_SYSTEMD_SLICE=", t);
+                                free(t);
+                                IOVEC_SET_STRING(iovec[n++], x);
+                        }
+
                         free(c);
                 }
 
@@ -897,8 +903,10 @@ static int system_journal_open(Server *s) {
         char ids[33];
 
         r = sd_id128_get_machine(&machine);
-        if (r < 0)
+        if (r < 0) {
+                log_error("Failed to get machine id: %s", strerror(-r));
                 return r;
+        }
 
         sd_id128_to_string(machine, ids);
 
@@ -1000,10 +1008,8 @@ int server_flush_to_var(Server *s) {
         log_debug("Flushing to /var...");
 
         r = sd_id128_get_machine(&machine);
-        if (r < 0) {
-                log_error("Failed to get machine id: %s", strerror(-r));
+        if (r < 0)
                 return r;
-        }
 
         r = sd_journal_open(&j, SD_JOURNAL_RUNTIME_ONLY);
         if (r < 0) {
@@ -1092,6 +1098,8 @@ int process_event(Server *s, struct epoll_event *ev) {
                 }
 
                 if (sfsi.ssi_signo == SIGUSR1) {
+                        log_info("Received request to flush runtime journal from PID %"PRIu32,
+                                 sfsi.ssi_pid);
                         touch("/run/systemd/journal/flushed");
                         server_flush_to_var(s);
                         server_sync(s);
@@ -1099,6 +1107,8 @@ int process_event(Server *s, struct epoll_event *ev) {
                 }
 
                 if (sfsi.ssi_signo == SIGUSR2) {
+                        log_info("Received request to rotate journal from PID %"PRIu32,
+                                 sfsi.ssi_pid);
                         server_rotate(s);
                         server_vacuum(s);
                         return 1;
@@ -1237,15 +1247,8 @@ int process_event(Server *s, struct epoll_event *ev) {
                         }
 
                         if (ev->data.fd == s->syslog_fd) {
-                                char *e;
-
                                 if (n > 0 && n_fds == 0) {
-                                        e = memchr(s->buffer, '\n', n);
-                                        if (e)
-                                                *e = 0;
-                                        else
-                                                s->buffer[n] = 0;
-
+                                        s->buffer[n] = 0;
                                         server_process_syslog_message(s, strstrip(s->buffer), ucred, tv, label, label_len);
                                 } else if (n_fds > 0)
                                         log_warning("Got file descriptors via syslog socket. Ignoring.");