OSSP CVS Repository

ossp - History for /ossp-pkg/l2/l2_test.c
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Directory]  [Omit Milestones

DateVersion Description
2005-Oct-03 10:08    1.56    Check-in [5217]: Adjust copyright messages for new year 2005. By rse. (diff)
2005-Jan-24 16:03    1.55    Check-in [4979]: Adjust copyright messages for new year 2005. By rse. (diff)
2003-Jun-30 13:13    1.54    Check-in [3466]: introduce "trunc=" option for file channel; change default to append; keep support for obsolete "append" option By thl. (diff)
2003-Feb-11 08:51    1.53    Check-in [3201]: fix all dmalloc-detected memory leaks By rse. (diff)
2003-Jan-27 17:01    1.52    Check-in [3091]: fix iteration through non malloc(3)ed memory in l2_channel_destroy(). Bug caught on FreeBSD5 By thl. (diff)
2003-Jan-06 12:41    1.51    Check-in [3065]: - remove trailing whitespaces - adjust copyright messages - consistently use "OSSP l2" - consistently talk about "Flexible Logging" - use standard OSSP ASCII-art By rse. (diff)
2002-Jul-30 21:08    1.50    Check-in [2437]: polish for release By rse. (diff)
2002-Jan-02 18:07    1.49    Check-in [1492]: bump copyright year By rse. (diff)
2001-Nov-30 10:44    1.48    Check-in [1389]: Allow a channel tree specification to be a printf-style string to make the API more powerful and to remove the burden from the application to pre-format the specification in an own buffer. By rse. (diff)
2001-Nov-16 20:40    1.47    Check-in [1354]: Mostly finished phase in of timer code to l2_env. Buffer needs work. By ms. (diff)
2001-Nov-08 22:58    1.46    Check-in [1286]: Enhance the specification parser to be more smart in parsing parameter values in order to remove the burden on the user to provide massive syntactic sugar.

One now can name=value or name="value" or even name=va"lu"e, i.e., do not require quotation marks. But if they are present they can be used to introduce spaces or special characters with \xXX notation. By rse. (diff)

2001-Nov-08 11:03    1.45    Check-in [1279]: fix old prefix problem, but find new one :-( By rse. (diff)
2001-Nov-07 17:17    1.44    Check-in [1265]: HEADS UP, guys:

Here comes the first cut for the long-awaited channel tree specification parser and channel tree builder. This certainly makes L2 finally THE killer library in the logging field. Woohooo... and the crowd goes wild!

It allows one to build an arbitrary complex logging channel tree out of a single textual specification. An example follows:

    noop -> {
        prefix(prefix="[%d-%m-%Y/%H:%M:%S] %L test[%P]: ", timezone="local")
        -> filter(regex="hecking", negate="0")
           -> buffer(size="800")
              -> file(path="l2_test.log",append="1",perm="420");
        error: syslog(ident="L2-Test", facility="user",
                      remotehost="en1", logpid="1", target="remote");
        panic: smtp(rcpt="rse@engelschall.com", host="en1", port="25"
    }

This allows one to log nice timestamp-prefixed messages containing the word "hecking" to a buffered file. Additionally if the message has a level higher or equal to "error" it also logs it remotely via UDP to the syslogd on en1. And additionally if the message is a panic message, it is also sent out as an Email via SMTP to the MTA on en1.

Ever thought a C library has to be dull and simple? ;)

PS: This stuff certainly needs more polishing and cleanup and also a few things I'll enhance in the future (for instance to remove the restriction that parameter values have to be in quotation marks, etc.). By rse. (diff)

2001-Nov-07 14:05    1.43    Check-in [1260]: Hell, I've seldom seen that it is needed to prepare and adjust such a lot of subtle details of existing code in order to make a new feature implementable in a straight-forward way. Anyway, here comes one more preparation change for the forthcoming channel tree specification parser:

- change l2_util_setparam() to take an l2_env_t parameter which allows the function to report better error messages.

- completely rewrite l2_util_setparam() to support calls l2_channel_configure(ch, "n1=v1,n2=v2,n3=v3") and/or l2_channel_configure(ch, "n1=%x,n2=%x,n3=%x", v1, v2, v3) instead of l2_channel_configure(ch, "n1,n2,n3", v1, v2, v3)

  This is both a step forward to make the interface of
  l2_channel_configure() more flexible (because one now can directly
  inline values instead of having them to be passed explicitly) and
  allows the spec parser not having to know the type (integer, floating
  point or string) of a parameter (which is important if one wants the
  parser to be independent of the implementing channel handlers).
 By rse. (diff)
2001-Nov-07 12:37    1.42    Check-in [1259]: More preparations for forthcoming channel tree specification parser (especially to allow the parser to determine the handler structure from a handler name without introducing another and this way redundant sub-API):

- add "char *name" to l2_handler_t in order to tag each handler structure with the corresponding channel name

- add l2_env_handler() function to add handler to l2_env_t objects. All l2_handler_xxxx are automatically pre-configured there after l2_env_create().

- change l2_channel_create() to take a "const char *name" (handler name) instead of the "l2_handler_t *h" (handler pointer) to make the stuff consistent and more clear.

- adjust l2_test.c to reflect the changes. By rse. (diff)

2001-Nov-06 16:02    1.41    Check-in [1257]: Change semantics of sibling linkage operations in order to fulfill the requirements in the forthcoming channel tree specification parser. By rse. (diff)
2001-Nov-05 21:39    1.40    Check-in [1256]: Seems like my long years of programming in assembly language still have an impact on my thinking. Change "nop" (assembly mnemonic) to "noop" (english abbreviation) in the name of our no-operation channel. Thanks to Michael for catching this. By rse. (diff)
2001-Nov-04 15:08    1.39    Check-in [1253]: Simplify "null" (discard) output channel to minimum implementation and provide an additional "nop" (no-operation) filter channel for typical use as the root channel in a channel tree. By rse. (diff)
2001-Nov-04 14:21    1.38    Check-in [1248]: Channel-Only Revamping Step 2: - moved code of l2_stream.c into (new) l2_env.c and l2_channel.c - created new l2_env_t and l2_env_xxx() - changed l2_xx_create() functions to also return l2_result_t - moved error handling into l2_env_t - replaced l2_channel_stack() with two new and more flexible l2_channel_link() and l2_channel_unlink() functions - rewritten test stuff in l2_test.c to use new structure - added new l2_channel_env() function for retriving l2_env_t

Puhhh.... By rse. (diff)

2001-Nov-03 23:51    1.37    Check-in [1247]: Channel-Only Revamping Step 1: allow multiple downstream channels in order to approach the later tree-like channel-only structure. By rse. (diff)
2001-Nov-03 21:49    1.36    Check-in [1246]: - change protocol parameter from "IPPROTO_XXX" to just "xxx" - add support for numerical and textual ports - add UDP support - remove unused iSocket variable - fix massive memory leaks on channel destruction - generally simplify implementation - cleanup coding style By rse. (diff)
2001-Nov-02 19:42    1.35    Check-in [1245]: Partially rewrote the socket channel to use the OSSP socket abstraction library. Channel still needs UDP configuration and writing logic. By ms. (diff)
2001-Oct-22 18:32    1.34    Check-in [1200]: Completed implementation of timer. Beware of scope problem - I have only tested it, but not proven it correct. By ms. (diff)
2001-Oct-05 16:25    1.33    Check-in [1082]: Changed timer from VIRTUAL to REAL. Completed flush alarm mechanism which seems to work, probably because we are not forking. By ms. (diff)
2001-Oct-05 12:40    1.32    Check-in [1073]: Added untested code to implement alarm exceptions in the buffer channel. The buffer will auto-flush after a user specified timeout if it is even possible to do this with a c-style exception handler. By ms. (diff)
2001-Oct-04 16:58    1.31    Check-in [1071]: Birth of IRC channel. By ms. (diff)
2001-Oct-04 15:35    1.30    Check-in [1070]: More socket channel configuration parameter adjustments. By ms. (diff)
2001-Oct-04 14:53    1.29    Check-in [1069]: Pipe and socket channel configuration-time parameter improvements. By ms. (diff)
2001-Sep-28 16:28    1.28    Check-in [1044]: Fixed bug of incorrectly checking the result of a call to pcre_study(), and later testing the return of pcre_exec(). Added code to test the filter channel. By ms. (diff)
2001-Sep-21 19:30    1.27    Check-in [1024]: Followup this suspicion later to remove unnecessary junk. By ms. (diff)
2001-Sep-19 18:39    1.26    Check-in [1021]: New implementation of signal handler and process control logic, improved reliability, some redesign, and test logic. By ms. (diff)
2001-Sep-18 16:41    1.25    Check-in [1020]: Fixed missing ifdef WITH_SOCKET. By ms. (diff)
2001-Sep-18 16:38    1.24    Check-in [1019]: Pipe channel handler redesign, bugfixes, and cleanup. By ms. (diff)
2001-Sep-14 21:11    1.23    Check-in [1016]: Revamp Syslog output channel. It now fully supports local AND remote logging. The local variant is still based on syslog(3), the remote variant is based on manual network connections with the syslog protocol as defined in RFC3164. By rse. (diff)
2001-Sep-14 20:49    1.22    Check-in [1014]: wrap things with WITH_XXX By rse. (diff)
2001-Sep-14 17:40    1.21    Check-in [1013]: Added the Thomas signal handler to catch SIGCHLD and SIGPIPE, pipe handler is now a filter not an output, new logic to test code, bugfixes. By ms. (diff)
2001-Sep-13 18:19    1.20    Check-in [993]: Added debug infrastructure, assertions, fixed one bug. By ms. (diff)
2001-Sep-12 15:50    1.19    Check-in [957]: First cut for flush mask support. By rse. (diff)
2001-Sep-12 15:05    1.18    Check-in [956]: add support for %L (level) and %P (pid) to prefix channel By rse. (diff)
2001-Sep-10 16:34    1.17    Check-in [924]: Added provisional testing of syslog channel. Once syslog is trimmed or redesigned, this test code will reflect the changes. By ms. (diff)
2001-Sep-09 18:01    1.16    Check-in [902]: Cleanup socket stuff and add SMTP test. By rse. (diff)
2001-Sep-08 13:25    1.15    Check-in [892]: do not use C++ comments By rse. (diff)
2001-Sep-06 21:29    1.14    Check-in [882]: More kludges to test sockets UDP and IPv6. By ms. (diff)
2001-Sep-06 13:56    1.13    Check-in [871]: Add two cool extra formatter functions ;)

l2_util_fmt_string: This can be used like %s, but instead of fetching only a "char *" from the var-args stack, it fetches a "char *" plus a "size_t" and this way allows one to log only a sub-string of a larger string without the need for any temporary buffers, etc.

l2_util_fmt_dump: This can be used as "%{type}X" for dumping arbitrary octets. The parameter "type" can be either "text" (the default if only "%X" is used) for dumping the octets as text but with non-printable characters replaced by "\xXX" constructs; "hex" for dumping the octets in hexadecimal as "XX:XX:XX:XX" or "base64" for dumping the octets Base64 encoded. All three are intended for making it easier to produce reasonable L2_LEVEL_DEBUG messages without having to fiddle around with temporary buffers and having to care with non-printable characters.

For instance, using...

      :
  l2_stream_formatter(st, 'D', l2_util_fmt_dump, NULL);
      :
  l2_stream_vlog(st, L2_LEVEL_DEBUG, "%{text}D %{hex}D %{base64}D\n",
                 "foo", 12345, "foo\1bar", 7, "foo\1bar", 7, "foo\1bar", 7);
      :

...produces "foo\x01bar 66:6f:6f:01:62:61:72 Zm9vAWJhcg==" in the output. By rse. (diff)

2001-Sep-05 15:56    1.12    Check-in [864]: Implemented prefix channel plus mini test. By rse. (diff)
2001-Sep-04 21:35    1.11    Check-in [849]: Array bug fixes and code to test sockets. By ms. (diff)
2001-Sep-04 16:56    1.10    Check-in [842]: cleanup level API (no need for retrieving old mask just in one function - either in all or in none). By rse. (diff)
2001-Sep-04 16:46    1.9    Check-in [839]: make static By rse. (diff)
2001-Sep-04 16:23    1.8    Check-in [838]: Much more beautiful formatter callback (whitespace cleanup.) By ms. (diff)
2001-Sep-04 16:17    1.7    Check-in [837]: Bugfixes and new format testing. By ms. (diff)
2001-Sep-03 15:43    1.6    Check-in [825]: - replace "int" with "l2_result_t" in L2 channel API - use a 2^n for L2_LEVEL_XXX in order to be able to create mask - remember loglevel for each channel - rewrite test suite By rse. (diff)
2001-Sep-02 17:38    1.5    Check-in [821]: Added configuration and opening of buffer and file channels. By ms. (diff)
2001-Aug-15 12:36    1.4    Check-in [675]: Fix more ossp.com references by replacing with the correct domain name ossp.org. By rse. (diff)
2001-May-17 16:42    1.3    Check-in [472]: Wrote a small test program for the library. By simons. (diff)
2001-May-12 09:23    1.2    Check-in [464]: - Add copyrights - use l2++.h in C++ test By rse. (diff)
2001-May-10 21:46    1.1    Check-in [449]: Initial revision By rse.
2001-May-10 21:46    1.1.1.1    Check-in [450]: L2 initial source tree By rse. (diff)

CVSTrac 2.0.1