fanf: (Default)
[personal profile] fanf

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...

Date: 2008-04-10 17:58 (UTC)
simont: A picture of me in 2016 (Default)
From: [personal profile] simont
Which probably means that you do still have copyright, since AIUI you automatically have it on anything you write unless you specifically waive it.

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?

Date: 2008-04-11 08:16 (UTC)
bens_dad: (Default)
From: [personal profile] bens_dad
I would then have an entirely free choice of what licence to put the whole lot under?

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...

December 2025

S M T W T F S
 123456
78910111213
14151617181920
21222324 252627
28293031   

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated 2025-12-30 04:09
Powered by Dreamwidth Studios