## ## OSSP fsl - Faking Syslog Library ## Copyright (c) 2002 Ralf S. Engelschall ## Copyright (c) 2002 The OSSP Project ## Copyright (c) 2002 Cable & Wireless Deutschland ## ## This file is part of OSSP fsl, a syslog(3) API faking library which ## can be found at http://www.ossp.org/pkg/lib/fsl/. ## ## Permission to use, copy, modify, and distribute this software for ## any purpose with or without fee is hereby granted, provided that ## the above copyright notice and this permission notice appear in all ## copies. ## ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ## SUCH DAMAGE. ## ## fsl.pod: OSSP fsl manual page ## =pod =head1 NAME B - Faking Syslog Library =head1 VERSION OSSP fsl FSL_VERSION_STR =head1 SYNOPSIS LDFLAGS="`fsl-config --all --ldflags`" \ LIBS="`fsl-config --all --libs`" \ ./configure [...] =head1 DESCRIPTION B offers the syslog(3) API otherwise provided by the Standard C Library (F). Instead of writing to the syslogd(8) process, it uses the powerful B logging capabilities. It is a drop-in link-time replacement which enables any syslog(3) consumer to take advantage of B by just linking this library in before F. The source code of the program remains unchanged. =head1 OPERATION If an application calls openlog(3) it passes an identification string (I) and a logging facility (I) along. B tries to read the file "CCI". If the file is not readable, all files matching IC are read. In both cases, all data that has been read in is then parsed for configuration sections. These are identified by "CI" at the beginning of a line. The I argument is a PCRE (Perl Compatible Regular Expression) that is matched against a string concatenated from "I/I" given to the openlog(3) call. The configuration section contains an B specification enclosed in curly brackets and terminated with a semicolon. The B specification may contain $1 ... $9 variables which are filled in from the I regex parts enclosed in round brackets. The $0 variable captures the wholly match and $$ diverts to a single escaped $. An B channel tree is build from each matching section and all found trees are merged together with a "null" channel to form a single tree. Further calls to syslog(3) will then inject log messages into this channel tree. =head1 L2SPEC The "logging library" (L2) builds its working configuration using a global environment object and channels which are interconnected to form a tree. The environment object holds general internal information and maintains the registration of formatters. The channels are used to process the logging message and use formatters to transform it. The root channel of the tree and each intermediate channel might have one or more children below it, passing the processed message down the tree. The leafs of the tree are constructed by channels specifically designed for outputting the message. Every logging message is injected into a channel, most likely the uppermost one, and traverses down the tree where channels with multiple children duplicate the message. L2 allows a developer to build this tree programmatically. In addition, L2 also supports building up the channel tree using a text based specification called the l2spec. The l2spec offers maximum flexibility as a program can read a l2spec created by a system administrator and pass it to L2 verbatim without even knowing anything about existing channels. When this approach is used, a newly designed channel can be used by an existing program by just linking in the latest lib_l2. The main program remains unmodified. B ::= B B ::= B | B '->' B | B '->' '{' B '}' B ::= B | B ';' B B ::= B '/' B ':' B | B ':' B | B B ::= B | '(' B ')' B ::= B | B '|' B B ::= 'panic' | 'critical' | 'error' | 'warning' | 'notice' | 'info' | 'trace' | 'debug' B ::= B B B ::= 'buffer' | 'fd' | 'file' | 'filter' | 'irc' | 'noop' | 'null' | 'pipe' | 'prefix' | 'smtp' | 'socket' | 'syslog' | ... B ::= I | '(' ')' | '(' B ')' B ::= B | B ',' B B ::= B '=' B B ::= m/[a-zA-Z][a-zA-Z0-9_-]*/ B ::= single-quoted, double-quoted or unquoted text Here is a table of available channels that lists their B and B including the type of each parameter. FIXME mandatories, defaults, output vs. filterchannels buffer (INT size, INT interval, INT levelflush); fd (INT filedescriptor); file (STR path, INT append, INT perm); filter (STR regex, INT negate, INT nocase); irc (STR progname, STR localhost, STR localuser, STR nickname, STR username, STR realname, STR channel, INT join, STR host, STR port, INT timeout); noop () null () pipe (STR execmode, STR runtime, STR path); prefix (STR prefix, STR timezone); smtp (STR progname, STR localhost, STR localuser, STR from, STR rcpt, STR subject, STR host, STR port, INT timeout); socket (STR proto, STR host, STR port, INT timeout); syslog (STR target, STR remotehost, INT remoteport, STR localhost, STR facility, STR ident, INT logpid); EXAMPLE for a very simple l2spec writing to STDERR (FD#2) fd(filedescriptor=2) EXAMPLE for a simple l2spec writing to a file file(path="/var/log/file") EXAMPLE for a very complex l2spec noop -> { (info): filter( regex="foo" ) -> syslog( remotehost="localhost" ); info: prefix( ) -> { debug/error: buffer( size=1024 ) -> file( path="a" ); (trace|debug)/(trace): buffer( size=65536 ) -> file( path="b" ) }; prefix() -> { warning: filter( negate=1, regex="foo" ) -> irc( host=irc.dev.de.cw.net ); error: filter( nocase=1, regex="foo" ) -> smtp( host=sv1.dev.de.cw.net ); panic: smtp( host=sv1.dev.de.cw.net ) } }; =head1 EXAMPLE ident sendmail/.* { debug: prefix(prefix="%%b %%d %%H:%%M:%%S <%%L> $1 [%%P]: ", timezone=local) -> file(path="sendmail.debug.log", append=0,perm=432) }; =head1 FILES The B library reads configuration sections located in one or more files. The path to the directory containing these file(s) is specified at compile time and is given to the configure script via C<--with-cfgdir=>I. F<@sysconfdir@/fsl.*> =head1 OPENPKG OpenPKG RPM packages must require the package "fsl" in both C and C and force the packaged application to link against F. =head1 SEE ALSO syslog(3), B http://www.ossp.org/pkg/lib/l2/, B http://www.ossp.org/pkg/lib/cfg/, B http://www.openpkg.org/. =head1 ONLINE RESOURCES Project Homepage: http://www.ossp.org/pkg/lib/fsl/ Source Repository: http://cvs.ossp.org/pkg/lib/fsl/ Distribution Files: ftp://ftp.ossp.org/pkg/lib/fsl/ =head1 HISTORY B was implemented in July 2002 by Thomas Lotterer for use in the B project as a replacement for its old B library. It was prompted by the necessarity to log to multiple files in the B F package and to write messages of particular log levels to different files in the B F package. =head1 AUTHOR Thomas Lotterer =cut