supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: Guillermo <gdiazhartusch@gmail.com>
To: Supervision <supervision@list.skarnet.org>
Subject: Re: s6-log problem with +regex
Date: Thu, 9 May 2019 23:27:19 -0300	[thread overview]
Message-ID: <CADQ2Nw_dC7Qj7SBAwvDy+SEHkhoBLQXRoP=37roy3V6BRAG__Q@mail.gmail.com> (raw)
In-Reply-To: <1fd4f712-f743-68ff-f648-151004ecfb0b@heuristicsystems.com.au>

Hi,

El jue., 9 may. 2019 a las 22:03, Dewayne Geraghty escribió:
>
> My test comprised an input /tmp/af with the intention of
> four separate s6-log managed logdirs. The logdirs' structure was
> correctly created, however three contained the same content, and the
> default contained nothing.  So the reduced form of testing looks like this:
> # cat /tmp/af   # a file of text to be processed
> a line of text not selected
> b nother line of text
> c more lines
> [date] with line of text
>
> The intention is to create a separate log based on a regex of the first
> character.

Did you want something like this (in shell)?

/usr/local/bin/s6-log - +^a /tmp/a-only - +^b /tmp/b-only - +^c
/tmp/c-only - +^\\\[ /tmp/date-only - f /tmp/default </tmp/af

> The following places the content of /tmp/af into /tmp/date-only.
>
> #!/usr/local/bin/execlineb -P ; # The testing script
> redirfd -r 0 /tmp/af
> /usr/local/bin/s6-log -b n3 +^\\\[ /tmp/date-only  f s100 S1500 T
> /tmp/default

Yes, because at the beginning of directive processing, all input lines
are implicitly selected. Therefore, a '+' directive does nothing if
there aren't any '-' directives preceding it that deselect something:
anything it selects is already selected.

> The following works correctly, in that date-only does not contain the
> [date] line.  It does contain the rest of /tmp/af, while /tmp/default
> does contain only the date (input line).
>
> # cat s6-test.sh
> #!/usr/local/bin/execlineb -P
> redirfd -r 0 /tmp/af
> /usr/local/bin/s6-log -b n3 -^\\\[ /tmp/date-only  f s100 S1500 T
> /tmp/default

Yes, because at the beginning of directive processing, all input lines
are implicitly selected, and then the '-' directive deselects those
that start with '[', so /tmp/date-only contains everything except
those lines. The 'f' directive selects lines that start with '[',
because, quoting the documentation, those are the ones "that have not
yet been acted upon (i.e. that were always deselected when the script
encountered an action directive)", so /tmp/default contains only them.
The "action directive" that "acts upon" the other lines in this
context is '/tmp/date-only' (an automatically rotated logdir
directive).

> Incidentally using the s6-log command
> /usr/local/bin/s6-log -b n3 +^\\\[ /tmp/date-only  s10 S150 T +^b
> /tmp/b-only  f s100 S1500 T /tmp/default
> results in both
> /tmp/date-only/current and /tmp/b-only/current
> containing all of /tmp/af, /tmp/default had the expected structure but
> empty current file.

Yes, same as the first example. '+' directives that aren't preceded by
'-' directives that deselect something do nothing, therefore
/tmp/date-only and /tmp/b-only are copies of /tmp/af. And because
there are no lines "that have not yet been acted upon" (all of them
have been "acted upon" by the '/tmp/date-only' and '/tmp/b-only'
directives), the 'f' directive selects nothing and /tmp/default is
empty.

> PS I haven't made sense of the hyphen in the example, after "E500 - " on
> page https://www.skarnet.org/software/s6/s6-log.html.

It deselects all lines.

>  Testing resulted in
> s6-log: fatal: unrecognized directive: -

Oh? It works for me...

G.


  reply	other threads:[~2019-05-10  2:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-10  1:02 Dewayne Geraghty
2019-05-10  2:27 ` Guillermo [this message]
2019-05-10  2:38 ` Laurent Bercot
2019-05-10  4:52   ` Dewayne Geraghty
2019-05-10 14:23     ` Laurent Bercot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADQ2Nw_dC7Qj7SBAwvDy+SEHkhoBLQXRoP=37roy3V6BRAG__Q@mail.gmail.com' \
    --to=gdiazhartusch@gmail.com \
    --cc=supervision@list.skarnet.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).