From: Kevin Berry <deathsyn@gmail.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: supervision@list.skarnet.org
Subject: Re: [PATCH] svlogd: implement option to use alternate config file
Date: Wed, 31 Jul 2019 14:12:59 -0500 [thread overview]
Message-ID: <CAORb_gAqa8VPHKomxEaSRPDr4s8cY6jJdg7TKk9HyafVYaw5-Q@mail.gmail.com> (raw)
In-Reply-To: <c60e7b048d972c180235d057791c74df8879b804.1564595967.git.ps@pks.im>
[-- Attachment #1: Type: text/plain, Size: 4381 bytes --]
I always used symlinks for common configuration of svlogd, but I guess this
could be a useful feature.
On Wed, Jul 31, 2019 at 1:27 PM Patrick Steinhardt <ps@pks.im> 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 <ps@pks.im>
> ---
>
> 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
next prev parent reply other threads:[~2019-07-31 19:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-31 18:00 Patrick Steinhardt
2019-07-31 19:12 ` Kevin Berry [this message]
2019-07-31 19:25 ` Patrick Steinhardt
2019-08-01 6:43 ` Jan Braun
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=CAORb_gAqa8VPHKomxEaSRPDr4s8cY6jJdg7TKk9HyafVYaw5-Q@mail.gmail.com \
--to=deathsyn@gmail.com \
--cc=ps@pks.im \
--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).