goetia
software
0x53.net

The log directory

The log directory is where all properly logged goetia services have their logs stored. By default, all services that write their logs to their stdout which is consumed by a logging process running s6-log. s6-log may manipulate the logs (e.g. add timestamps) before it writes them to files in a directory, one directory per service.

The default system log directory is @syslogdir@/system. @syslogdir@ is /var/log by default and can be changed at compile time, using the --syslogdir=@syslogdir@ switch to the ./configure script.

The user log directories are at ${HOME}/.local/state/log/@USERTREE@. This can be changed using the --usrlogdir=@usrlogdir@ switch to the ./configure script. ${HOME} wil be prepended, resulting in ${HOME}/@usrlogdir@/@USERTREE@.

Both types of log directories have the following structure:

/path/to/logdir
├── @LONGRUNSERVICE1@
└── @LONGRUNSERVICE2@
		

Where all directories dubbed @SERVICE1@, @SERVICE2@, ... correspond to one service and are of the logdir format from s6-log.

The logging chain

In goetia, each longrun service @LONGRUN@-srv comes with another dedicated service @LONGRUN@-log for logging it. This logging service runs the s6-log program. s6-log then writes the logs to a log directory, e.g. @syslogdir@/system/@LONGRUN@ for a service of the system supervision tree. s6-log takes care of prepending timestamps and automatic log rotations and has many more optional features documented on its own page.

This is accomplished as follows: s6-rc establishes anonymous pipes using s6-rc-fdholder-filler. They are automatically connected to stdout of @LONGRUN@-srv and stdin of @LONGRUN@-log. This is also why all example scripts on this page and all source directories run, up and down scripts contain

fdmove -c 2 1
				

in one of the first lines. It does nothing more than copying the stderr to the stdout of @LONGRUN@-srv, so that both arrive at the stdin of @LONGRUN@-log.

The following situations, however, need to be handled differently:

In all of these cases, the messages are "propagated up" to s6-svscan. s6-svscan, in turn, has its own logging service, e.g. s6-svscan-log in case of the system supervision tree. All logs that arrive at s6-svscan are forwarded to this logger.

See also: the logging chain part of the s6-log page.

Automatic logger creation

It would be tedious to create ever the same logging services for each longrun manually. For that reason, goetia includes system-ml and user-ml. These programs automatically create logging services for all longrun services they find in their corresponding configuration directory.

The automatically generated logging services of the system supervision tree, run as the user logger. This can be changed by the --loguser=... flag to the ./configure script.

Additionally they have a dependency to the standard bundle mount. This can be changed by the --logdep=... flag to the ./configure script. Whatever the dependency is, it is crucial that it makes sure the partition containing @syslogdir@/system is mounted writable.

Manual logger creation

There are cases where a distinct (i.e. not autogenerated standard logger) logger for some services is desired. An example would be running (some or all) logging daemons with the permissions of a different user to fine tune reading permissions.

It is possible to set this up for select services alongside automatic logger generation for the other services. To achieve this, do the following.