[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
where to put helper to send stdout/stderr to syslog?
From: |
Robert Vollmert |
Subject: |
where to put helper to send stdout/stderr to syslog? |
Date: |
Sun, 16 Jun 2019 14:22:14 +0200 |
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
- where to put helper to send stdout/stderr to syslog?,
Robert Vollmert <=