From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 23767 invoked from network); 25 Oct 2022 16:12:47 -0000 Received: from alyss.skarnet.org (95.142.172.232) by inbox.vuxu.org with ESMTPUTF8; 25 Oct 2022 16:12:47 -0000 Received: (qmail 7347 invoked by uid 89); 25 Oct 2022 16:13:10 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Received: (qmail 7340 invoked from network); 25 Oct 2022 16:13:10 -0000 From: "Laurent Bercot" To: "supervision@list.skarnet.org" Subject: Re: ca catchall logger prefix log lines with service names? Date: Tue, 25 Oct 2022 16:12:43 +0000 Message-Id: In-Reply-To: <20221025141920.rxxk6qkxpggloryt@localhost> References: <20221025141920.rxxk6qkxpggloryt@localhost> Reply-To: "Laurent Bercot" User-Agent: eM_Client/9.1.2109.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable >I am trying to figure out if I can set up svscan catchall logger in such >a way that it prepends a service name to every log line, so that it can >be clear where the log came from. > >I am trying to avoid s6-rc setup where I need to explicitly create a >matching logger service. You are saying "I want to use s6 without adopting s6 idioms because I'm used to the way other supervisors do things, even when they're giant hacks." :) It's much easier to have one dedicated set of logs per service, and merge them later if that's what you want, than to have one big blob of logs and separate them later for analysis. In other words: "cat | sort" is cheaper than a series of "grep". The catch-all logger is exactly what it says: a catch-all. It only gets the logs that are not diverted; it's not supposed to get *everything* - although it can, if that's what you want, but then as you noticed you get everything as is: output from the services go directly to the catch-all logger. There is no intermediary process that can prepend your log lines with information, because the services have their output directly plugged into the pipe to the catch-all=20 logger. The only way to modify the log lines is to insert an additional process between your service and the catch-all logger that performs the modification. And the simplest way to achieve that is to have a foo/log service (or a foo-log consumer, if you're using s6-rc) for every foo producer, that processes its stdin and writes the modified lines to stdout, something like s6-format-filter "foo: %s" But that's still defining a consumer for your service. There is, unfortunately, no way to do that without a consumer for every service. And if you're going to add consumers anyway, you may as well write dedicated loggers directly instead of line processors that send everything back to the catch-all logger. Note that it's not s6 being difficult; it's s6 being out of the way by default, by not touching your logs. If another supervisor allows you to modify log lines by default, it means it's inserting itself between the service and its logger, which is terribly inefficient. >But creates a log file where all logs from all services are mixed up and >are impossible to distinguish. There is already a strange looking thing >prepended to every line (@400000006356da4b2cb3ba0a - a timestamp?) Yes, it's a TAI64N timestamp. Process the file through s6-tai64nlocal to get human-readable timestamps. One of the advantages of TAI64N stamps is that they're alphabetically sorted, so you can merge several log files into one via "cat log1 log2 log3... | sort". -- Laurent