head 1.34;
access;
symbols
L2_0_9_13:1.34
FSL_1_7_0:1.34
L2_0_9_12:1.34
LMTP2NNTP_1_4_1:1.34
LMTP2NNTP_1_4_0:1.34
FSL_1_6_1:1.34
L2_0_9_11:1.34
FSL_1_6_0:1.33
FSL_1_6b2:1.33
L2_0_9_10:1.33
FSL_1_6b1:1.33
L2_0_9_9:1.33
LMTP2NNTP_1_3_0:1.32
LMTP2NNTP_1_3b2:1.32
LMTP2NNTP_1_3b1:1.32
LMTP2NNTP_1_3a3:1.32
FSL_1_5_0:1.32
LMTP2NNTP_1_3a2:1.32
FSL_1_5a3:1.32
LMTP2NNTP_1_3a1:1.32
FSL_1_5a2:1.32
L2_0_9_8:1.32
FSL_1_5a1:1.32
L2_0_9_7:1.32
L2_0_9_6:1.32
FSL_1_4_0:1.32
FSL_1_4b1:1.32
L2_0_9_5:1.32
FSL_1_4a1:1.31
FSL_1_3_0:1.31
FSL_1_3b1:1.31
L2_0_9_4:1.31
FSL_1_2_1:1.31
L2_0_9_3:1.31
FSL_1_2_0:1.31
L2_0_9_2:1.31
FSL_1_1_0:1.31
FSL_1_1b1:1.31
WORKOFF:1.31.0.2
WORKOFF_BP:1.31
FSL_1_0_8:1.31
LMTP2NNTP_1_2_0:1.31
LMTP2NNTP_1_2b4:1.31
LMTP2NNTP_1_2b3:1.31
LMTP2NNTP_1_2b2:1.31
LMTP2NNTP_1_2b1:1.31
LMTP2NNTP_1_2a8:1.31
LMTP2NNTP_1_2a7:1.31
FSL_1_0_7:1.31
FSL_1_0_6:1.30
FSL_1_0_5:1.30
FSL_1_0_4:1.30
L2_0_9_1:1.30
FSL_1_0_3:1.30
LMTP2NNTP_1_2a6:1.30
FSL_1_0_2:1.30
FSL_1_0_1:1.30
FSL_1_0_0:1.30
FSL_0_9_0:1.30
L2_0_9_0:1.30
FSL_0_1_12:1.29
FSL_0_1_11:1.29
FSL_0_1_10:1.29
FSL_0_1_9:1.29
FSL_0_1_8:1.29
FSL_0_1_7:1.29
FSL_0_1_6:1.29
FSL_0_1_5:1.29
FSL_0_1_1:1.29
LMTP2NNTP_1_2a5:1.28
LMTP2NNTP_1_2a4:1.28
LMTP2NNTP_1_2a3:1.28
LMTP2NNTP_1_2a1:1.24
LMTP2NNTP_1_1_1:1.13
LMTP2NNTP_1_1_0:1.13
LMTP2NNTP_1_1b4:1.13
LMTP2NNTP_1_1b3:1.13
L2_CHANNEL_ONLY_REVAMPING_BEFORE:1.13
LMTP2NNTP_1_1b2:1.13
LMTP2NNTP_1_1b1:1.13
L2_0_1_0:1.6;
locks; strict;
comment @# @;
1.34
date 2005.10.03.08.08.11; author rse; state Exp;
branches;
next 1.33;
1.33
date 2005.01.24.15.03.17; author rse; state Exp;
branches;
next 1.32;
1.32
date 2003.11.10.15.12.48; author thl; state Exp;
branches;
next 1.31;
1.31
date 2003.01.06.11.41.51; author rse; state Exp;
branches;
next 1.30;
1.30
date 2002.07.30.19.08.24; author rse; state Exp;
branches;
next 1.29;
1.29
date 2002.07.17.11.22.08; author thl; state Exp;
branches;
next 1.28;
1.28
date 2002.01.30.15.42.44; author rse; state Exp;
branches;
next 1.27;
1.27
date 2002.01.02.17.07.38; author rse; state Exp;
branches;
next 1.26;
1.26
date 2001.12.22.22.18.34; author rse; state Exp;
branches;
next 1.25;
1.25
date 2001.12.14.12.39.08; author rse; state Exp;
branches;
next 1.24;
1.24
date 2001.11.30.09.44.47; author rse; state Exp;
branches;
next 1.23;
1.23
date 2001.11.16.19.53.05; author ms; state Exp;
branches;
next 1.22;
1.22
date 2001.11.16.19.40.55; author ms; state Exp;
branches;
next 1.21;
1.21
date 2001.11.07.16.17.09; author rse; state Exp;
branches;
next 1.20;
1.20
date 2001.11.07.13.05.20; author rse; state Exp;
branches;
next 1.19;
1.19
date 2001.11.07.11.37.18; author rse; state Exp;
branches;
next 1.18;
1.18
date 2001.11.06.15.02.49; author rse; state Exp;
branches;
next 1.17;
1.17
date 2001.11.05.20.39.35; author rse; state Exp;
branches;
next 1.16;
1.16
date 2001.11.04.14.08.24; author rse; state Exp;
branches;
next 1.15;
1.15
date 2001.11.04.13.21.17; author rse; state Exp;
branches;
next 1.14;
1.14
date 2001.11.03.22.51.36; author rse; state Exp;
branches;
next 1.13;
1.13
date 2001.10.09.15.34.55; author rse; state Exp;
branches;
next 1.12;
1.12
date 2001.10.09.14.03.04; author ms; state Exp;
branches;
next 1.11;
1.11
date 2001.09.27.07.16.25; author rse; state Exp;
branches;
next 1.10;
1.10
date 2001.09.25.15.22.21; author ms; state Exp;
branches;
next 1.9;
1.9
date 2001.09.13.19.20.48; author rse; state Exp;
branches;
next 1.8;
1.8
date 2001.09.13.19.18.34; author rse; state Exp;
branches;
next 1.7;
1.7
date 2001.09.13.16.32.12; author ms; state Exp;
branches;
next 1.6;
1.6
date 2001.09.12.13.50.46; author rse; state Exp;
branches;
next 1.5;
1.5
date 2001.09.12.10.24.29; author ms; state Exp;
branches;
next 1.4;
1.4
date 2001.09.12.09.42.34; author ms; state Exp;
branches;
next 1.3;
1.3
date 2001.09.10.10.15.11; author thl; state Exp;
branches;
next 1.2;
1.2
date 2001.09.10.09.54.41; author thl; state Exp;
branches;
next 1.1;
1.1
date 2001.09.10.09.48.48; author thl; state Exp;
branches;
next ;
desc
@@
1.34
log
@Adjust copyright messages for new year 2005.
@
text
@/*
** OSSP l2 - Flexible Logging
** Copyright (c) 2001-2005 Cable & Wireless
** Copyright (c) 2001-2005 The OSSP Project
** Copyright (c) 2001-2005 Ralf S. Engelschall
**
** This file is part of OSSP l2, a flexible logging library which
** can be found at http://www.ossp.org/pkg/lib/l2/.
**
** 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.
**
** l2.h: C API
*/
#ifndef __L2_H__
#define __L2_H__
/* version information (compile-time) */
#define L2_VERSION_STR "@@L2_VERSION_STR@@"
#define L2_VERSION_HEX @@L2_VERSION_HEX@@
/* version information (run-time) */
typedef struct {
const int v_hex;
const char *v_short;
const char *v_long;
const char *v_tex;
const char *v_gnu;
const char *v_web;
const char *v_sccs;
const char *v_rcs;
} l2_version_t;
extern l2_version_t l2_version;
/* include standard environment we are based on */
#include
#include
#include
#include
/* counterbalance poor standard environments */
#ifndef NULL
#define NULL (void *)0
#endif
#ifndef FALSE
#define FALSE (0)
#endif
#ifndef TRUE
#define TRUE (!FALSE)
#endif
/* forward declarations for opaque data structures */
union l2_context_un;
struct l2_param_st;
struct l2_stream_st;
struct l2_channel_st;
struct l2_handler_st;
struct l2_env_st;
/* corresponding data types for data structures */
typedef union l2_context_un l2_context_t;
typedef struct l2_param_st l2_param_t;
typedef struct l2_handler_st l2_handler_t;
typedef struct l2_stream_st l2_stream_t;
typedef struct l2_channel_st l2_channel_t;
typedef struct l2_env_st l2_env_t;
/* list of logging levels (high to low priority; low to high amount of logging) */
typedef enum {
L2_LEVEL_NONE = 0,
L2_LEVEL_PANIC = (1 << 0),
L2_LEVEL_CRITICAL = (1 << 1),
L2_LEVEL_ERROR = (1 << 2),
L2_LEVEL_WARNING = (1 << 3),
L2_LEVEL_NOTICE = (1 << 4),
L2_LEVEL_INFO = (1 << 5),
L2_LEVEL_TRACE = (1 << 6),
L2_LEVEL_DEBUG = (1 << 7)
} l2_level_t;
/* macro describing a particular custom level */
#define L2_LEVEL_CUSTOM(n) (1 << (8+(n))
/* macro describing all levels */
#define L2_LEVEL_ALL ((1 << (8+9+1))-1)
/* macro describing all levels from highest (PANIC)
to and including a particular low level */
#define L2_LEVEL_UPTO(level) (((level)-1)|(level))
/* list of return values */
typedef enum {
L2_OK, /* everything ok */
L2_OK_PASS, /* everything ok - pass downstream */
L2_ERR_ARG, /* invalid argument */
L2_ERR_USE, /* invalid usage */
L2_ERR_MEM, /* no more memory available */
L2_ERR_SYS, /* system error (see errno) */
L2_ERR_IO, /* input/output error */
L2_ERR_FMT, /* message formating error */
L2_ERR_INT, /* internal error */
L2_ERR_SYN, /* syntax error */
L2_ERR_CH /* no (more) channel found */
} l2_result_t;
/* context union for storing data */
union l2_context_un {
char c;
short s;
int i;
long l;
float f;
double d;
char *cp;
void *vp;
};
/* list of types for storing data */
typedef enum {
L2_TYPE_INT,
L2_TYPE_FLT,
L2_TYPE_STR
} l2_type_t;
/* parameter specification */
struct l2_param_st {
char *name;
l2_type_t type;
void *store;
};
/* parameter constructors */
#define L2_PARAM_SET(pa,n,t,s) \
pa.name = #n, pa.type = L2_TYPE_##t, pa.store = s
#define L2_PARAM_END(pa) \
pa.name = NULL
/* list of handler types */
typedef enum {
L2_CHANNEL_FILTER,
L2_CHANNEL_OUTPUT
} l2_chtype_t;
/* list of linking modes */
typedef enum {
L2_LINK_CHILD,
L2_LINK_SIBLING
} l2_link_t;
/* channel handler specification structure */
struct l2_handler_st {
const char *name;
l2_chtype_t type;
l2_result_t (*create) (l2_context_t *ctx, l2_channel_t *ch);
l2_result_t (*configure)(l2_context_t *ctx, l2_channel_t *ch, const char *fmt, va_list ap);
l2_result_t (*open) (l2_context_t *ctx, l2_channel_t *ch);
l2_result_t (*write) (l2_context_t *ctx, l2_channel_t *ch, l2_level_t level, const char *buf, size_t bufsize);
l2_result_t (*flush) (l2_context_t *ctx, l2_channel_t *ch);
l2_result_t (*close) (l2_context_t *ctx, l2_channel_t *ch);
l2_result_t (*destroy) (l2_context_t *ctx, l2_channel_t *ch);
};
/* type of formatter callback function */
typedef l2_result_t (*l2_formatter_t)(
l2_context_t *ctx, /* application context */
const char id, /* input arg: format string id ('x' of '%x') */
const char *param, /* input arg: format string parameter ('foo' of '%{foo}x') */
char *bufptr, /* input arg: pointer to output buffer */
size_t bufsize, /* input arg: maximum size of output buffer */
size_t *buflen, /* ouput arg: written characters in output buffer */
va_list *ap /* in/out arg: variable argument pointer */
);
/* list of shipped (output) channel handlers (pre-configured in l2_env_t objects) */
extern l2_handler_t l2_handler_null;
extern l2_handler_t l2_handler_fd;
extern l2_handler_t l2_handler_file;
extern l2_handler_t l2_handler_pipe;
extern l2_handler_t l2_handler_socket;
extern l2_handler_t l2_handler_syslog;
extern l2_handler_t l2_handler_smtp;
/* list of shipped (filter) channel handlers (pre-configured in l2_env_t objects) */
extern l2_handler_t l2_handler_noop;
extern l2_handler_t l2_handler_filter;
extern l2_handler_t l2_handler_prefix;
extern l2_handler_t l2_handler_buffer;
/* context operations */
l2_result_t l2_env_create (l2_env_t **env);
l2_result_t l2_env_destroy (l2_env_t *env);
l2_result_t l2_env_levels (l2_env_t *env, unsigned int levelmask, unsigned int flushmask);
l2_result_t l2_env_formatter (l2_env_t *env, char id, l2_formatter_t cb, l2_context_t *ctx);
l2_result_t l2_env_handler (l2_env_t *env, l2_handler_t *h);
l2_result_t l2_env_errorinfo (l2_env_t *env, l2_result_t rv, const char *fmt, ...);
char *l2_env_strerror (l2_env_t *env, l2_result_t rv);
l2_result_t l2_env_settimer (l2_env_t *env, int iInterval);
/* channel operations */
l2_result_t l2_channel_create (l2_channel_t **ch, l2_env_t *env, const char *name);
l2_result_t l2_channel_destroy (l2_channel_t *ch);
l2_result_t l2_channel_levels (l2_channel_t *ch, unsigned int levelmask, unsigned int flushmask);
l2_result_t l2_channel_configure (l2_channel_t *ch, const char *fmt, ...);
l2_result_t l2_channel_open (l2_channel_t *ch);
l2_result_t l2_channel_write (l2_channel_t *ch, l2_level_t level, const char *buf, size_t bufsize);
l2_result_t l2_channel_flush (l2_channel_t *ch);
l2_result_t l2_channel_close (l2_channel_t *ch);
l2_result_t l2_channel_log (l2_channel_t *ch, l2_level_t level, const char *fmt, ...);
l2_result_t l2_channel_vlog (l2_channel_t *ch, l2_level_t level, const char *fmt, va_list ap);
l2_result_t l2_channel_link (l2_channel_t *ch, l2_link_t id, l2_channel_t *ch2, ...);
l2_result_t l2_channel_unlink (l2_channel_t *ch);
l2_result_t l2_channel_upstream (l2_channel_t *ch, l2_channel_t **chU);
l2_result_t l2_channel_downstream (l2_channel_t *ch, l2_channel_t **chD);
l2_result_t l2_channel_type (l2_channel_t *ch, l2_chtype_t *type);
l2_result_t l2_channel_env (l2_channel_t *ch, l2_env_t **env);
/* channel tree specification operations */
l2_result_t l2_spec (l2_channel_t **ch, l2_env_t *env, const char *spec, ...);
l2_result_t l2_vspec (l2_channel_t **ch, l2_env_t *env, const char *spec, va_list ap);
/* utility operations */
l2_result_t l2_util_setparams (l2_env_t *env, l2_param_t p[], const char *fmt, va_list ap);
l2_result_t l2_util_l2s (char *string, size_t maxlen, int sep, unsigned int levelmask);
l2_result_t l2_util_s2l (const char *string, size_t maxlen, int sep, unsigned int *levelmask);
l2_result_t l2_util_fmt_string (l2_context_t *, const char, const char *, char *, size_t, size_t *, va_list *);
l2_result_t l2_util_fmt_dump (l2_context_t *, const char, const char *, char *, size_t, size_t *, va_list *);
l2_result_t l2_util_fmt_errno (l2_context_t *, const char, const char *, char *, size_t, size_t *, va_list *);
#endif /* __L2_H__ */
@
1.33
log
@Adjust copyright messages for new year 2005.
@
text
@d3 3
a5 3
** Copyright (c) 2001-2004 Cable & Wireless
** Copyright (c) 2001-2004 The OSSP Project
** Copyright (c) 2001-2004 Ralf S. Engelschall
@
1.32
log
@remove non-generic code (possibly leaked from lmtp2nntp) as it violates prefix-safety and collides with Darwin log2() math function
@
text
@d3 3
a5 3
** Copyright (c) 2001-2003 Cable & Wireless Deutschland GmbH
** Copyright (c) 2001-2003 The OSSP Project (http://www.ossp.org/)
** Copyright (c) 2001-2003 Ralf S. Engelschall
@
1.31
log
@- remove trailing whitespaces
- adjust copyright messages
- consistently use "OSSP l2"
- consistently talk about "Flexible Logging"
- use standard OSSP ASCII-art
@
text
@a106 7
/* macros for easy logging */
#define log0(ctx,level,msg) l2_channel_log((ctx)->l2, L2_LEVEL_##level, "%P" msg)
#define log1(ctx,level,msg,a1) l2_channel_log((ctx)->l2, L2_LEVEL_##level, "%P" msg, a1)
#define log2(ctx,level,msg,a1,a2) l2_channel_log((ctx)->l2, L2_LEVEL_##level, "%P" msg, a1, a2)
#define log3(ctx,level,msg,a1,a2,a3) l2_channel_log((ctx)->l2, L2_LEVEL_##level, "%P" msg, a1, a2, a3)
#define log4(ctx,level,msg,a1,a2,a3,a4) l2_channel_log((ctx)->l2, L2_LEVEL_##level, "%P" msg, a1, a2, a3, a4)
@
1.30
log
@polish for release
@
text
@d2 4
a5 3
** OSSP l2 - Logging Library
** Copyright (c) 2001-2002 The OSSP Project (http://www.ossp.org/)
** Copyright (c) 2001-2002 Cable & Wireless Deutschland (http://www.cw.com/de/)
d7 1
a7 1
** This file is part of OSSP L2, a flexible logging library which
d57 1
a57 1
/* counterbalance poor standard environments */
d92 1
a92 1
L2_LEVEL_INFO = (1 << 5),
d103 1
a103 1
/* macro describing all levels from highest (PANIC)
@
1.29
log
@added errno formatter from lmtp2nntp
@
text
@d2 1
a2 1
** L2 - OSSP Logging Library
d7 1
a7 1
** can be found at http://www.ossp.org/pkg/l2/.
@
1.28
log
@make logX utility macros public
@
text
@d249 1
@
1.27
log
@bump copyright year
@
text
@d102 1
a102 1
/* macr describing all levels from highest (PANIC)
d105 7
@
1.26
log
@Fix l2_spec_error function and remove again the not
really needed l2_env_verrorinfo function.
@
text
@d3 2
a4 2
** Copyright (c) 2001 The OSSP Project (http://www.ossp.org/)
** Copyright (c) 2001 Cable & Wireless Deutschland (http://www.cw.com/de/)
@
1.25
log
@provide l2_env_verrorinfo() and a new L2_ERR_SYN
@
text
@a210 1
l2_result_t l2_env_verrorinfo (l2_env_t *env, l2_result_t rv, const char *fmt, va_list ap);
@
1.24
log
@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.
@
text
@d117 1
d211 1
@
1.23
log
@Whoops, corrected function prototype.
@
text
@d232 2
a233 1
l2_result_t l2_spec (l2_channel_t **ch, l2_env_t *env, const char *spec);
@
1.22
log
@Mostly finished phase in of timer code to l2_env. Buffer needs work.
@
text
@d211 1
a211 1
l2_result_t l2_env_settimer (l2_env_t *env, int iInterval)
@
1.21
log
@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.).
@
text
@d211 1
@
1.20
log
@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).
@
text
@d230 3
@
1.19
log
@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.
@
text
@a133 2
L2_TYPE_CHAR,
L2_TYPE_SHORT,
d135 2
a136 6
L2_TYPE_LONG,
L2_TYPE_FLOAT,
L2_TYPE_DOUBLE,
L2_TYPE_STRING,
L2_TYPE_CHARPTR,
L2_TYPE_VOIDPTR
d231 1
a231 1
l2_result_t l2_util_setparams (l2_param_t p[], const char *fmt, va_list ap);
@
1.18
log
@Change semantics of sibling linkage operations in order to fulfill the
requirements in the forthcoming channel tree specification parser.
@
text
@d172 1
d194 1
a194 1
/* list of shipped (output) channel handlers */
d203 1
a203 1
/* list of shipped (filter) channel handlers */
d214 1
d219 1
a219 1
l2_result_t l2_channel_create (l2_channel_t **ch, l2_env_t *env, l2_handler_t *h);
@
1.17
log
@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.
@
text
@d166 2
a167 2
L2_LINK_CHILDS,
L2_LINK_SIBLINGS
@
1.16
log
@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.
@
text
@d203 1
a203 1
extern l2_handler_t l2_handler_nop;
@
1.15
log
@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....
@
text
@d203 1
@
1.14
log
@Channel-Only Revamping Step 1:
allow multiple downstream channels in order to
approach the later tree-like channel-only structure.
@
text
@d73 1
d81 1
d95 2
a97 1
#define L2_LEVEL_ALL ((1 << (8+9+1))-1)
d99 6
a104 3
/* all levels from highest (PANIC) to and including a particular low level */
#define L2_LEVEL_UPTO(level) \
(((level)-1)|(level))
d164 6
d207 8
d216 3
a218 1
l2_channel_t *l2_channel_create (l2_handler_t *h);
d224 4
a227 2
l2_result_t l2_channel_destroy (l2_channel_t *ch);
l2_result_t l2_channel_stack (l2_channel_t *ch, l2_channel_t *chTop);
d231 1
a231 12
l2_result_t l2_channel_errorinfo (l2_channel_t *ch, l2_result_t rv, const char *fmt, ...);
char *l2_channel_strerror (l2_channel_t *ch, l2_result_t rv);
/* stream operations */
l2_stream_t *l2_stream_create (void);
l2_result_t l2_stream_channel (l2_stream_t *st, l2_channel_t *ch, unsigned int levelmask, unsigned int flushmask);
l2_result_t l2_stream_formatter (l2_stream_t *st, char id, l2_formatter_t cb, l2_context_t *ctx);
l2_result_t l2_stream_levels (l2_stream_t *st, unsigned int levelmask, unsigned int flushmask);
l2_result_t l2_stream_log (l2_stream_t *st, l2_level_t level, const char *fmt, ...);
l2_result_t l2_stream_vlog (l2_stream_t *st, l2_level_t level, const char *fmt, va_list ap);
l2_result_t l2_stream_flush (l2_stream_t *st);
l2_result_t l2_stream_destroy (l2_stream_t *st);
d234 5
a238 5
l2_result_t l2_util_setparams (l2_param_t p[], const char *fmt, va_list ap);
l2_result_t l2_util_l2s (char *string, size_t maxlen, int sep, unsigned int levelmask);
l2_result_t l2_util_s2l (const char *string, size_t maxlen, int sep, unsigned int *levelmask);
l2_result_t l2_util_fmt_string (l2_context_t *, const char, const char *, char *, size_t, size_t *, va_list *);
l2_result_t l2_util_fmt_dump (l2_context_t *, const char, const char *, char *, size_t, size_t *, va_list *);
@
1.13
log
@Veto: back-out latest level-related changes.
Sorry, Michael, the padding has to be done in l2_ch_prefix.c only.
@
text
@d102 2
a103 1
L2_OK,
d110 2
a111 1
L2_ERR_INT /* internal error */
d204 3
a206 2
l2_channel_t *l2_channel_downstream (l2_channel_t *ch);
l2_chtype_t l2_channel_type (l2_channel_t *ch);
@
1.12
log
@Corrected prefix functionality, because channel write operations do not take
level masks as input.
@
text
@d219 2
a220 2
l2_result_t l2_util_l2s (char *string, size_t maxlen, l2_level_t level);
l2_result_t l2_util_s2l (const char *string, size_t maxlen, l2_level_t *level);
@
1.11
log
@add a convinient level mask which includes all levels
@
text
@d219 2
a220 2
l2_result_t l2_util_l2s (char *string, size_t maxlen, int sep, unsigned int levelmask);
l2_result_t l2_util_s2l (const char *string, size_t maxlen, int sep, unsigned int *levelmask);
@
1.10
log
@Got rid of compile warnings and made minor TRACE modifications. Sorry, but
there is no way to use a va_list in a TRACE call. TRACE is a macro that
expands anywhere in source, so a va_list declaraction will sometimes violate
ANSI c decl specs.
@
text
@d94 1
@
1.9
log
@For consistency reasons provide a l2_stream_flush() function
which allows one to flush all channel (stacks) in one action.
@
text
@d203 2
@
1.8
log
@use assert(3) instead of home-brewn stuff
@
text
@d211 1
@
1.7
log
@Added assertion macro for debugging purposes.
@
text
@a66 13
#ifndef DEBUG
#define ASSERT(expr) ((voir)0)
#else
#define ASSERT(expr)\
do {\
if (!(expr)) {\
fprintf(stderr, "Assertion failed in %s line %d! ", __FILE__, __LINE__);\
exit(1);\
}\
}\
while (0)
#endif
@
1.6
log
@First cut for flush mask support.
@
text
@d67 13
@
1.5
log
@Merged new L2_LEVEL_NONE enum value from l2.h source file.
@
text
@d206 1
a206 1
l2_result_t l2_stream_channel (l2_stream_t *st, l2_channel_t *ch, unsigned int levelmask);
d208 1
a208 1
l2_result_t l2_stream_levels (l2_stream_t *st, unsigned int levelmask);
@
1.4
log
@Upgraded both stream and channel-level APIs to include new L2_LEVEL parameter design.
@
text
@d83 1
@
1.3
log
@no need to double-declare the version stuff
@
text
@d160 1
a160 1
l2_result_t (*write) (l2_context_t *ctx, l2_channel_t *ch, const char *buf, size_t bufsize);
d195 1
a195 1
l2_result_t l2_channel_write (l2_channel_t *ch, const char *buf, size_t bufsize);
d208 2
a209 2
l2_result_t l2_stream_log (l2_stream_t *st, unsigned int level, const char *fmt, ...);
l2_result_t l2_stream_vlog (l2_stream_t *st, unsigned int level, const char *fmt, va_list ap);
@
1.2
log
@a string is a string ;)
@
text
@d33 1
d36 13
@
1.1
log
@add version information to public API
@
text
@d33 1
a33 1
#define L2_VERSION_STR @@L2_VERSION_STR@@
@