unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* where to put helper to send stdout/stderr to syslog?
@ 2019-06-16 12:22 Robert Vollmert
  2019-06-17 12:45 ` Danny Milosavljevic
  0 siblings, 1 reply; 6+ messages in thread
From: Robert Vollmert @ 2019-06-16 12:22 UTC (permalink / raw)
  To: guix-devel

Hi all,

I came up with the following wrapper that uses logger to redirect a
program’s console output to syslog:

(define* (logger-wrapper name exec . args)
  "Return a derivation that builds a script to start a process with
standard output and error redirected to syslog via logger."
  (define exp
    #~(begin
        (use-modules (ice-9 popen))
        (let* ((pid  (number->string (getpid)))
               (cmd  (string-append "logger -t " #$name " --id=" pid))
               (log  (open-output-pipe cmd)))
          (dup log 1)
          (dup log 2)
          (execl #$exec #$exec #$@args))))
  (program-file (string-append name "-logger") exp))

I use it as follows for a service that doesn’t support syslog:

(shepherd-service
  ...
  (start #~(make-forkexec-constructor
             '(#$(logger-wrapper “postgrest” (file-append postgrest “/bin/postgrest”)))
             …

Would logger-wrapper be generally useful to have available? If so,
is it named well, and where would it fit?

Cheers
Robert

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-06-18 16:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-16 12:22 where to put helper to send stdout/stderr to syslog? Robert Vollmert
2019-06-17 12:45 ` Danny Milosavljevic
2019-06-17 13:12   ` Robert Vollmert
2019-06-17 14:45     ` Danny Milosavljevic
2019-06-18 13:32   ` Ludovic Courtès
2019-06-18 16:44     ` Robert Vollmert

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).