Selog - selective logging

Selog is a library of routines that unifies error reporting,
activity logging, and debug tracing. It allows programmers to give
their users flexible control over which messages are written and
where they are written to.

Selog is designed to be as simple as possible while still being
extremely efficient, powerful, and flexible. The essence of selog
is:

Obtain a configuration string from the user, which looks like:

+log_pid+example@syslog;-example@stderr

When the program starts, initialize selog with the user's configuration.

selog_open(config, spelling)

Define a selector for each different kind of message.

static selog_selector sel = SELINIT("example", SELOG_INFO);

Use the selog() function to emit messages instead of printf() or syslog().

selog(sel, "message number %d", n);

Selectors determine which messages are written and where they are
written to, under the control of the user's configuration. You can
direct messages to any combination of stderr, syslog, files, pipes,
etc. You can omit or include optional parts of messages under the
control of selectors. You don't have to signal the program when you
rotate its log files.

The C interface consists of just 13 functions, 5 macros, 2 types,
and an enum. There are a few variations of the basic selog()
one-shot logging function, or you can quickly and easily compose
messages in stages. The check to skip disabled messages is extremely
small and fast.

Selog can be used with C99 and C++. It comes with shell command and
Lua interfaces, plus interposition libraries which you can use to
fool old code that calls err() or syslog() into
using selog instead.

Changes

8.7.30

C++ support (suggested by Rich Wareham)

Mac OS portability (Rich Wareham)

Embedded version strings

8.4.10

Initial release

Selog is written by Tony Finch
<dot@dotat.at>
<fanf2@cam.ac.uk>
at the University of Cambridge Computing Service.
You may do anything with it, at your own risk.
$Cambridge: users/fanf2/selog/Web/index.html,v 1.10 2008/07/30 18:21:11 fanf2 Exp $