On Wed, Jul 31, 2019 at 02:12:59PM -0500, Kevin Berry wrote:
> I always used symlinks for common configuration of svlogd, but I guess this
> could be a useful feature.

Yeah, I thought about using a symlink here, too. The main reason
why I didn't want to do this is to keep configuration and data
separate from each other. It honestly feels a bit weird to me to
configure the logger in /var/log/$service -- doing so in
/etc/sv/$service/log seems like the more obvious location to me
and can be cleanly achieved with this new option without
requiring a symlink.

> 
> On Wed, Jul 31, 2019 at 1:27 PM Patrick Steinhardt <[email protected]> wrote:
> 
> > Right now, the svlogd daemon will always look up the log configuration
> > in the target log directory itself. There's reasons though for having
> > the configuration file located at a different place, e.g. to provide a
> > global log configuration or to separate data from configuration.
> >
> > Introduce a new command line option, "-c", that takes as parameter an
> > alternative log file. It can either be given a relative path, in which
> > case svlogd will try to open it relative to the log directories, or an
> > absolute path, where it will try to use a single configuration for each
> > of the log directories.
> >
> > Add tests to verify that svlogd is correctly reading the alternative
> > configuration file.
> >
> > Signed-off-by: Patrick Steinhardt <[email protected]>
> > ---
> >
> > Hi,
> >
> > I don't quite know whether this is the right place to send
> > patches to, but runit's homepage didn't mention any way to
> > contribute patches (or I didn't find it). Please feel free to
> > redirect me if I've chosen the wrong place.
> >
> > Regards
> > Patrick
> >
> >  man/svlogd.8     | 15 ++++++++++++++-
> >  src/svlogd.c     | 11 ++++++++---
> >  src/svlogd.check | 10 ++++++++++
> >  src/svlogd.dist  |  5 +++++
> >  4 files changed, 37 insertions(+), 4 deletions(-)
> >
> > diff --git a/man/svlogd.8 b/man/svlogd.8
> > index 01b2324..5359d94 100644
> > --- a/man/svlogd.8
> > +++ b/man/svlogd.8
> > @@ -3,7 +3,8 @@
> >  svlogd \- runit's service logging daemon
> >  .SH SYNOPSIS
> >  .B svlogd
> > -[\-tttv] [\-r
> > +[\-tttv] [\-c
> > +.I file\fR] [\-r
> >  .I c\fR] [\-R
> >  .I xyz\fR] [\-l
> >  .I len\fR] [\-b
> > @@ -377,6 +378,18 @@ the form YYYY-MM-DDTHH:MM:SS.xxxxx when writing to
> >  .I log
> >  or to standard error.
> >  .TP
> > +.B \-c \fIfile
> > +config file.
> > +Use
> > +.I file
> > +as configuration instead of the default
> > +.I log/config
> > +path.
> > +.I file
> > +may either be absolute or relative, in which case it will be relative to
> > the
> > +.I log
> > +directory.
> > +.TP
> >  .B \-r \fIc
> >  replace.
> >  .I c
> > diff --git a/src/svlogd.c b/src/svlogd.c
> > index 90a3321..0109684 100644
> > --- a/src/svlogd.c
> > +++ b/src/svlogd.c
> > @@ -49,6 +49,7 @@ unsigned long linemax =1000;
> >  unsigned long buflen =1024;
> >  unsigned long linelen;
> >
> > +const char *config = "config";
> >  const char *replace ="";
> >  char repl =0;
> >
> > @@ -437,13 +438,14 @@ unsigned int logdir_open(struct logdir *ld, const
> > char *fn) {
> >    while (! stralloc_copys(&ld->processor, "")) pause_nomem();
> >
> >    /* read config */
> > -  if ((i =openreadclose("config", &sa, 128)) == -1)
> > +  if ((i =openreadclose(config, &sa, 128)) == -1)
> >      warn2("unable to read config", ld->name);
> >    if (i != 0) {
> >      int len, c;
> >      unsigned long port;
> >
> > -    if (verbose) strerr_warn4(INFO, "read: ", ld->name, "/config", 0);
> > +    if (verbose && *config != '/') strerr_warn5(INFO, "read: ", ld->name,
> > "/", config, 0);
> > +    else if (verbose) strerr_warn3(INFO, "read: ", config, 0);
> >      for (i =0; i +1 < sa.len; ++i) {
> >        len =byte_chr(&sa.s[i], sa.len -i, '\n');
> >        sa.s[len +i] =0;
> > @@ -667,8 +669,11 @@ int main(int argc, const char **argv) {
> >
> >    progname =*argv;
> >
> > -  while ((opt =getopt(argc, argv, "R:r:l:b:tvV")) != opteof) {
> > +  while ((opt =getopt(argc, argv, "c:R:r:l:b:tvV")) != opteof) {
> >      switch(opt) {
> > +    case 'c':
> > +      config =optarg;
> > +      break;
> >      case 'R':
> >        replace =optarg;
> >        if (! repl) repl ='_';
> > diff --git a/src/svlogd.check b/src/svlogd.check
> > index 7d926ef..e9584ee 100755
> > --- a/src/svlogd.check
> > +++ b/src/svlogd.check
> > @@ -24,4 +24,14 @@ echo t2 >"${ctmp}"/config
> >  echo $?
> >  cat "${ctmp}"/current
> >
> > +echo prelative-alternate >"${ctmp}"/alternate-config
> > +echo foo |svlogd -c alternate-config "${ctmp}"
> > +echo $?
> > +cat "${ctmp}"/current
> > +
> > +echo pabsolute-alternate >>"${ctmp}"/alternate-config
> > +echo foo |svlogd -c "${ctmp}"/alternate-config "${ctmp}"
> > +echo $?
> > +cat "${ctmp}"/current
> > +
> >  rm -rf "${ctmp}"
> > diff --git a/src/svlogd.dist b/src/svlogd.dist
> > index b3329e6..8570230 100644
> > --- a/src/svlogd.dist
> > +++ b/src/svlogd.dist
> > @@ -19,3 +19,8 @@ baz
> >  :ar
> >  :az
> >  0
> > +0
> > +relative-alternatefoo
> > +0
> > +relative-alternatefoo
> > +absolute-alternatefoo
> > --
> > 2.22.0
> >
> >
> 
> -- 
> Kevin Berry

Attachment: signature.asc
Description: PGP signature

Reply via email to