Re: Prepending log lines with custom tag

From: Laurent Bercot <ska-skaware_at_skarnet.org>
Date: Wed, 21 Sep 2016 10:13:08 +0000

>In my mind I would need to:
>- process the output from the fifo by prepending a tag,
>- move the processed output to stdin where s6-log can pick it up
  If you read your logs from a fifo, then it's easy: use the
integrated pipe mechanism in s6-svscan. Your "logging service",
say foo-log, would read from the fifo and prepend the lines
with a tag, then pipe its data to the foo-log/log service
(a "logger for your logging service") which would perform the
logging per se.

  Something like:

foo-log/run:

#!/usr/bin/execlineb -PW
  redirfd -rnb 0 /var/run/itrp/foo-log-fifo
  s6-format-filter "foo: %s"


foo-log/log/run:

#!/usr/bin/execlineb -PW
s6-envdir /var/run/s6/container_environment
importas -is S6_LOGGING_SCRIPT S6_LOGGING_SCRIPT
s6-log -bp -- ${S6_LOGGING_SCRIPT} /var/log/foo


  If you're already reading your logs from the integrated
pipe instead of a fifo (i.e. your logging service is foo/log)
then you can modify your service layout to reduce to the
former case.

  I hope to be able to work on a new s6-overlay format next
year, using s6-rc, which makes those "log pipelines" easy to
set up.

  Hope this helps,

--
  Laurent
Received on Wed Sep 21 2016 - 10:13:08 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC