all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Danny Milosavljevic <dannym@scratchpost.org>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: Re: shepherd logging
Date: Sat, 17 Feb 2018 00:17:01 +0100	[thread overview]
Message-ID: <20180217001701.08999f49@scratchpost.org> (raw)
In-Reply-To: <20180216220737.0b5b7c0d@scratchpost.org>

Aaand it works on Linux - shepherd messages show up on the console and eventually
end up in syslog (I checked).  Integration is surprisingly easy and safe (shepherd
already does line buffering manually):

diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index ccf62a6e2..168495c14 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -169,7 +169,15 @@ and provides a \"top-like\" mode (monitoring).")
               (patches (search-patches "shepherd-close-fds.patch"))))
     (build-system gnu-build-system)
     (arguments
-     '(#:configure-flags '("--localstatedir=/var")))
+     '(#:configure-flags '("--localstatedir=/var")
+       #:tests? #f ; I broke them, sorry
+       #:phases
+       (modify-phases %standard-phases
+        (add-after 'unpack 'patch-kmsg
+          (lambda _
+            (substitute* "modules/shepherd/support.scm"
+             (("%localstatedir \"/log/shepherd.log\"") "\"/dev/kmsg\""))
+            #t)))))
     (native-inputs
      `(("pkg-config" ,pkg-config)

Timestamp is printed twice, though (shepherd prints one, too).

$ cat /var/log/messages
[...]
Feb 16 23:01:58 localhost vmunix: [    9.178841] Console: switching to colour frame buffer device 160x50
Feb 16 23:01:58 localhost vmunix: [    9.198267] i915 0000:00:02.0: fb0: inteldrmfb frame buffer device
Feb 16 23:01:58 localhost vmunix: [    9.229274] 2018-02-16 23:01:32 Service udev has been started. <----- hellooooo
Feb 16 23:01:58 localhost vmunix: [   25.232541] NET: Registered protocol family 38

Note: 9.229274 is [Fr Feb 16 23:01:32 2018] (as checked by "dmesg -T"),
so syslogd is kinda off here.  Maybe they print the time of their /dev/kmsg
readout action... that would be weird.

Maybe this would remove the duplicate timestamp:

diff --git a/modules/shepherd/comm.scm b/modules/shepherd/comm.scm
index 0228f63..4048315 100644
--- a/modules/shepherd/comm.scm
+++ b/modules/shepherd/comm.scm
@@ -51,6 +51,7 @@
             start-logging
             stop-logging
             %current-client-socket
+            %current-logfile-date-format
             shepherd-output-port))
 
 ^L
@@ -200,6 +201,9 @@ on service '~a':")
   ;; Socket of the client currently talking to the daemon.
   (make-parameter #f))
 
+(define %current-logfile-date-format
+  (make-parameter default-logfile-date-format))
+
 ;; We provide our own output mechanism, because we have certain
 ;; special needs; most importantly, we want to send output to herd
 ;; sometimes.
@@ -228,7 +232,7 @@ on service '~a':")
             (let* ((log (lambda (x)
                           (display x log-output-port)))
                    (init-line (lambda ()
-                                (log (strftime "%Y-%m-%d %H:%M:%S "
+                                (log (strftime %current-logfile-date-format
                                                (localtime (current-time)))))))
               (init-line)
               (for-each log (reverse buffer))
diff --git a/modules/shepherd/support.scm b/modules/shepherd/support.scm
index bb01edc..0df97ea 100644
--- a/modules/shepherd/support.scm
+++ b/modules/shepherd/support.scm
@@ -285,6 +285,11 @@ TARGET should be a string representing a filepath + name."
       (string-append %localstatedir "/log/shepherd.log")
       (string-append %user-config-dir "/shepherd.log")))
 
+(define default-logfile-date-format
+   (if (zero? (getuid))
+       (format #f "[~d]: " (getpid))
+       "%Y-%m-%d %H:%M:%S "))
+
 ;; Configuration file.
 (define (default-config-file)
   "Return the default configuration file---either the user's file, or the

Doesn't work on the Hurd (even cat /dev/klog hangs the Hurd).

  reply	other threads:[~2018-02-16 23:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-15 11:42 [bug#30464] [PATCH 0/2] Add console-agetty-service Danny Milosavljevic
2018-02-15 11:47 ` [bug#30464] [PATCH 1/2] services: " Danny Milosavljevic
2018-02-15 11:47   ` [bug#30464] [PATCH 2/2] services: agetty-shepherd-service: Default to providing 'term-console instead of 'term-auto Danny Milosavljevic
2018-02-15 14:40   ` [bug#30464] [PATCH 1/2] services: Add console-agetty-service Ludovic Courtès
2018-02-15 15:41     ` Danny Milosavljevic
2018-02-15 15:47       ` Ludovic Courtès
2018-02-16 20:57         ` [bug#30464] shepherd logging; console-agetty-service Danny Milosavljevic
2018-02-16 21:07           ` [bug#30464] shepherd logging Danny Milosavljevic
2018-02-16 23:17             ` Danny Milosavljevic [this message]
2018-02-17 16:25             ` Ludovic Courtès
2018-02-17 16:47               ` Danny Milosavljevic
2018-02-17 16:57                 ` Ludovic Courtès
2018-02-17 16:20           ` [bug#30464] shepherd logging; console-agetty-service Ludovic Courtès
2018-02-17 18:02             ` Danny Milosavljevic
2018-02-26 17:52         ` [bug#30464] [PATCH 1/2] services: Add console-agetty-service Ludovic Courtès
2020-10-08 18:21           ` Maxim Cournoyer
2022-01-13 16:02             ` [bug#30464] [PATCH 0/2] " zimoun
2022-02-03  2:33               ` zimoun
2022-02-03 20:55                 ` Danny Milosavljevic
2022-03-23 13:00                   ` zimoun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180217001701.08999f49@scratchpost.org \
    --to=dannym@scratchpost.org \
    --cc=guix-devel@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.