From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robert Vollmert Subject: where to put helper to send stdout/stderr to syslog? Date: Sun, 16 Jun 2019 14:22:14 +0200 Message-ID: Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:39568) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcUAx-00006R-Jw for guix-devel@gnu.org; Sun, 16 Jun 2019 08:22:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcUAw-0001TY-M1 for guix-devel@gnu.org; Sun, 16 Jun 2019 08:22:23 -0400 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]:26686) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcUAw-0001PQ-Ew for guix-devel@gnu.org; Sun, 16 Jun 2019 08:22:22 -0400 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id DDF814D85B for ; Sun, 16 Jun 2019 14:22:17 +0200 (CEST) Received: from smtp1.mailbox.org ([80.241.60.240]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id s05d5AK_sYcX for ; Sun, 16 Jun 2019 14:22:16 +0200 (CEST) List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org Hi all, I came up with the following wrapper that uses logger to redirect a program=E2=80=99s 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=3D" 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=E2=80=99t support syslog: (shepherd-service ... (start #~(make-forkexec-constructor '(#$(logger-wrapper =E2=80=9Cpostgrest=E2=80=9D = (file-append postgrest =E2=80=9C/bin/postgrest=E2=80=9D))) =E2=80=A6 Would logger-wrapper be generally useful to have available? If so, is it named well, and where would it fit? Cheers Robert