I'm pleased to announce the first release of selog, which you can download from <http://dotat.at/prog/selog/>.
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 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.
Selog's origins
I started work on selog when I found myself writing yet another half-arsed logging/debugging module that could only be used by the program it was written for. The problem needed to be solved properly, but I couldn't find a decent existing solution.
Exim's logging and debugging facilities provided the basis for selog's configuration syntax and the idea for the fast check to disable debugging code. Like many other programs, Exim's logging and debugging code is non-orthogonal and non-reusable; selog exists to avoid problems like Exim's fixed set of log files and the lack of debugging redirection.
The architecture of log4j and its many imitators provided many nice ideas to copy, in particular selog's selectors and channels are similar to log4j's loggers and appenders. However log4j is unnecessarily complicated, so selog discards plenty of its ideas, such as hierarchial category names and arbitrarily configurable message layouts. Bloaty log4c provided a salutory anti-pattern.
I've tried to make this first release fairly polished - e.g. it has comprehensive documentation - however it has not had its portability catches polished off, and in particular I'm going to be interested to see how much trouble my use of C99 features causes. The next step is to go back to the program that I wrote selog for, and put the code to use...
no subject
Date: 2008-04-10 14:36 (UTC)If the former, are you actually waiving copyright on the code, or merely granting an extremely permissive licence? Using "Written by" in place of "Copyright" suggests your intention might have been to do the former, but if I remember rightly, other copyright waivers I've seen have been rather more explicit and verbose.
no subject
Date: 2008-04-10 14:40 (UTC)no subject
Date: 2008-04-10 17:58 (UTC)So if, hypothetically, I were to include your library in a program of mine which did have a copyright notice, what would I have to do? My guess is that it would be some sort of misrepresentation to simply write "This software is copyright Simon Tatham", since not all of it would be. So presumably what would happen is that I'd have to put your name in the copyright statement, but that I would then have an entirely free choice of what licence to put the whole lot under?
no subject
Date: 2008-04-10 18:20 (UTC)Yes, and in fact it might not even be possible to waive it in some jurisdictions. There are also aspects of copyright that cannot be transferred, like the author's moral rights. But it seems silly to assert copyright above a license that's this liberal. On the other hand, I suppose a declaration by the author that a work is in the public domain will not be mis-interpreted even if it is technically incorrect.
So if, hypothetically, I were to include your library in a program of mine which did have a copyright notice, what would I have to do?
Anything you like.
no subject
Date: 2008-04-11 08:16 (UTC)Which might be very desirable. You can include it in your GPL'd package and I can include it in mine which is BSD or otherwise incompatible with the GPL...