New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vlogger(8) #65

Closed
wants to merge 9 commits into
base: master
from

Conversation

Projects
None yet
6 participants
@Duncaen
Contributor

Duncaen commented Mar 1, 2017

vlogger(8) is a alternative to logger(1), by default it sends messages
from stdin to syslog.

The main reason to replace logger(1) is, that logger only connects once to
the syslog socket in default mode and puts all messages into the void if
syslog is not running at the time.
logger(1) has a new --socket-errors=on mode which would work, but some
void uses don't use syslog at all and in this case the log service would
constantly restart.

As a bonus vlogger(8) looks for /etc/vlogger and if its executable it
just executes it and is replaced by it.
This can be used to avoid syslog and just write all logs to files with
svlogd(8) as example, without having to edit all log services.

VLOGGER(8)                  System Manager's Manual                 VLOGGER(8)

NAME
     vlogger – log messages to syslog or an arbitrary executable

SYNOPSIS
     vlogger [-p priority] [-t tag]

DESCRIPTION
     By default, vlogger reads lines from stdin and sends them to syslog.  If
     the file /etc/vlogger exists and is executable it is executed with tag as
     only argument and replaces vlogger.

     If vlogger is executed as a log service for runit or another daemontools
     like supervision suite it uses the service name as default tag.  As
     example if vlogger is linked to /var/service/foo/log/run it uses foo as
     default tag.

     -p priority
             The.  priority can be facility.level or just facility.  See
             FACILITIES, LEVELS or syslog(3).  The default is daemon.info.

     -t tag  Defines the openlog(3) ident which is used as prefix for each log
             message or passed as first argument to /etc/vlogger.

FACILITIES
     auth
     authpriv
     cron
     daemon
     ftp
     kern         can not be used from userspace replaced with daemon.
     lpr
     mail
     news
     syslog
     user
     uucp
     local[0-7]
     security     deprecated synonym for auth.

LEVELS
     emerg
     alert
     crit
     err
     warning
     notice
     info
     debug
     panic        deprecated synonym for emerg.
     error        deprecated synonym for err.
     warn         deprecated synonym for warning.

FILES
     /etc/vlogger
             An optional executable file that is used to to handle the
             messages.  It is executed with tag as first argument and replaces
             the vlogger process.

EXIT STATUS
     The vlogger utility exits 0 on success, and >0 if an error occurs.

EXAMPLES
     /etc/vlogger:

           #!/bin/sh
           exec svlogd /var/log/$1

SEE ALSO
     logger(1), syslog(3), svlogd(8)

HISTORY
     This program is a replacement for the logger utility provided by
     util-linux.

AUTHOR
     Duncan Overbruck <mail@duncano.de>

LICENSE
     vlogger is in the public domain.

     To the extent possible under law, the creator of this work has waived all
     copyright and related or neighboring rights to this work.

     http://creativecommons.org/publicdomain/zero/1.0/

Linux                            March 1, 2017                           Linux
Add vlogger(8)
vlogger(8) is a alternative to logger(1), by default it sends messages
from stdin to syslog.

The main reason to replace logger(1) is, that logger only connects once to
the syslog socket in default mode and puts all messages into the void if
syslog is not running at the time.
logger(1) has a new `--socket-errors=on` mode which would work, but some
void uses don't use syslog at all and in this case the log service would
constantly restart.

As a bonus vlogger(8) looks for /etc/vlogger and if its executable it
just executes it and is replaced by it.
This can be used to avoid syslog and just write all logs to files with
svlogd(8) as example, without having to edit all log services.
@CMB

This comment has been minimized.

Show comment
Hide comment
@CMB

CMB Apr 4, 2017

Contributor

Looks good!
I'd love to see this merged.

Contributor

CMB commented Apr 4, 2017

Looks good!
I'd love to see this merged.

@xtraeme

This comment has been minimized.

Show comment
Hide comment
@xtraeme

xtraeme Apr 5, 2017

Member
Member

xtraeme commented Apr 5, 2017

Show outdated Hide outdated vlogger.c
#include <syslog.h>
#include <unistd.h>
typedef struct _code {

This comment has been minimized.

@chneukirchen

chneukirchen Apr 5, 2017

Contributor

Don't use identifiers starting with _ in code.

@chneukirchen

chneukirchen Apr 5, 2017

Contributor

Don't use identifiers starting with _ in code.

Show outdated Hide outdated vlogger.c
if (((p = strrchr(*argv, '/')) && !strncmp(p+1, "run", 3)) &&
(*p = 0, (p = strrchr(*argv, '/')) && !strncmp(p+1, "log", 3)) &&
(*p = 0, (p = strrchr(*argv, '/'))) != 0) {
tag = strdup(p+1);

This comment has been minimized.

@chneukirchen

chneukirchen Apr 5, 2017

Contributor

unchecked strdup

@chneukirchen

chneukirchen Apr 5, 2017

Contributor

unchecked strdup

Show outdated Hide outdated vlogger.c
}
if (access("/etc/vlogger", X_OK) != -1)
execl("/etc/vlogger", "/etc/vlogger", tag, (char *)0);

This comment has been minimized.

@chneukirchen

chneukirchen Apr 5, 2017

Contributor

Do we want to fall back to the default if this execl fails?

@chneukirchen

chneukirchen Apr 5, 2017

Contributor

Do we want to fall back to the default if this execl fails?

@bougyman

This comment has been minimized.

Show comment
Hide comment
@bougyman

bougyman Apr 5, 2017

Member
Member

bougyman commented Apr 5, 2017

@chneukirchen

This comment has been minimized.

Show comment
Hide comment
@chneukirchen

chneukirchen Apr 5, 2017

Contributor

rsvlog does not support syslog, which we currently use on void.

I don't see how 100 loc .c can be overkill for something like this. ;)

Contributor

chneukirchen commented Apr 5, 2017

rsvlog does not support syslog, which we currently use on void.

I don't see how 100 loc .c can be overkill for something like this. ;)

@CMB

This comment has been minimized.

Show comment
Hide comment
@CMB

CMB Apr 16, 2017

Contributor

I found a couple more issues with vlogger in its current state.
It was possible for tag to be uninitialized.
Symlinking vlogger to foo/log/run didn't work as expected, because
runsv doesn't use an absolute pathname when running the service.
Instead, it changes to the service directory and executes ./run.
I fixed them both, on the vlogger branch of CMB/void-runit.

Contributor

CMB commented Apr 16, 2017

I found a couple more issues with vlogger in its current state.
It was possible for tag to be uninitialized.
Symlinking vlogger to foo/log/run didn't work as expected, because
runsv doesn't use an absolute pathname when running the service.
Instead, it changes to the service directory and executes ./run.
I fixed them both, on the vlogger branch of CMB/void-runit.

@the-maldridge

This comment has been minimized.

Show comment
Hide comment
@the-maldridge

the-maldridge Jun 29, 2017

Member

@Duncaen can we go ahead and merge this? Sounds like you may need to pull back in some changes from @CMB first though...

Member

the-maldridge commented Jun 29, 2017

@Duncaen can we go ahead and merge this? Sounds like you may need to pull back in some changes from @CMB first though...

@the-maldridge

This comment has been minimized.

Show comment
Hide comment
@the-maldridge

the-maldridge Jul 26, 2017

Member

I'd like to open the can of worms here and ask if this can be an OSI recognized license instead of cc0. As I've learned recently cc0 is incredibly hard to deal with for US based contributors in certain states.

Member

the-maldridge commented Jul 26, 2017

I'd like to open the can of worms here and ask if this can be an OSI recognized license instead of cc0. As I've learned recently cc0 is incredibly hard to deal with for US based contributors in certain states.

@CMB

This comment has been minimized.

Show comment
Hide comment
@CMB

CMB Jun 2, 2018

Contributor

Looks like this issue fell off the radar.

Contributor

CMB commented Jun 2, 2018

Looks like this issue fell off the radar.

CMB and others added some commits Apr 16, 2017

vlogger: Fix symlinked ./run handling, make sure tag is initialized.
If vlogger is symlinked to foo/log/run for some service foo,
it's invoked as ./run with $SERVICEDIR/foo/log as the cwd.
So extract the service name from cwd if argv[0] is ./run.
Also tag is initialized to the generic "vlogger" if it is
not given on the command line and servicename couldn't be extracted
from cwd.
@Duncaen

This comment has been minimized.

Show comment
Hide comment
@Duncaen

Duncaen Jun 3, 2018

Contributor

@CMB thanks for the reminder, merged your changes and did a few cleanups to not exit if anything related to getting the service name from the cwd. This should allow to set the tag via the t flag.
It checks if tag is initialized after opt parsing and exits if its not set via either cwd or options.

Contributor

Duncaen commented Jun 3, 2018

@CMB thanks for the reminder, merged your changes and did a few cleanups to not exit if anything related to getting the service name from the cwd. This should allow to set the tag via the t flag.
It checks if tag is initialized after opt parsing and exits if its not set via either cwd or options.

@Duncaen

This comment has been minimized.

Show comment
Hide comment
@Duncaen

Duncaen Jun 3, 2018

Contributor

@the-maldridge not sure about the license, the choice was made because everything else in this repository is already in the public domain.

Contributor

Duncaen commented Jun 3, 2018

@the-maldridge not sure about the license, the choice was made because everything else in this repository is already in the public domain.

@the-maldridge

This comment has been minimized.

Show comment
Hide comment
@the-maldridge

the-maldridge Jun 3, 2018

Member

@Duncaen good point, I'd somehow missed that entirely. As that's a separate issue, we can handle it in another thread. At this point I've got no remaining requests for this before merge.

:shipit:

Member

the-maldridge commented Jun 3, 2018

@Duncaen good point, I'd somehow missed that entirely. As that's a separate issue, we can handle it in another thread. At this point I've got no remaining requests for this before merge.

:shipit:

@Duncaen

This comment has been minimized.

Show comment
Hide comment
@Duncaen

Duncaen Jun 21, 2018

Contributor

Merged in the new repository.
void-linux/void-runit@b29a3c4

Contributor

Duncaen commented Jun 21, 2018

Merged in the new repository.
void-linux/void-runit@b29a3c4

@Duncaen Duncaen closed this Jun 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment