Index: ossp-pkg/l2/l2.h.in RCS File: /v/ossp/cvs/ossp-pkg/l2/l2.h.in,v rcsdiff -q -kk '-r1.5' '-r1.6' -u '/v/ossp/cvs/ossp-pkg/l2/l2.h.in,v' 2>/dev/null --- l2.h.in 2001/09/12 10:24:29 1.5 +++ l2.h.in 2001/09/12 13:50:46 1.6 @@ -203,9 +203,9 @@ /* 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); +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); +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_destroy (l2_stream_t *st); Index: ossp-pkg/l2/l2_p.h RCS File: /v/ossp/cvs/ossp-pkg/l2/l2_p.h,v rcsdiff -q -kk '-r1.15' '-r1.16' -u '/v/ossp/cvs/ossp-pkg/l2/l2_p.h,v' 2>/dev/null --- l2_p.h 2001/09/11 10:37:04 1.15 +++ l2_p.h 2001/09/12 13:50:46 1.16 @@ -61,6 +61,7 @@ typedef struct { l2_channel_t *ch; unsigned int levelmask; + unsigned int flushmask; } l2_channel_entry_t; typedef struct { @@ -71,6 +72,7 @@ struct l2_stream_st { unsigned int levelmask; + unsigned int flushmask; char message[L2_MAX_MSGSIZE]; l2_channel_entry_t channels[L2_MAX_CHANNELS]; l2_formatter_entry_t formatters[L2_MAX_FORMATTERS]; Index: ossp-pkg/l2/l2_stream.c RCS File: /v/ossp/cvs/ossp-pkg/l2/Attic/l2_stream.c,v rcsdiff -q -kk '-r1.15' '-r1.16' -u '/v/ossp/cvs/ossp-pkg/l2/Attic/l2_stream.c,v' 2>/dev/null --- l2_stream.c 2001/09/12 09:42:34 1.15 +++ l2_stream.c 2001/09/12 13:50:46 1.16 @@ -43,6 +43,7 @@ /* initialize stream structure */ st->levelmask = 0; + st->flushmask = 0; for (i = 0; i < L2_MAX_CHANNELS; i++) st->channels[i].ch = NULL; for (i = 0; i < L2_MAX_FORMATTERS; i++) @@ -52,7 +53,7 @@ } /* attach channel to stream */ -l2_result_t l2_stream_channel(l2_stream_t *st, l2_channel_t *ch, unsigned int levelmask) +l2_result_t l2_stream_channel(l2_stream_t *st, l2_channel_t *ch, unsigned int levelmask, unsigned int flushmask) { l2_channel_t *chC; l2_channel_t *chN; @@ -79,6 +80,7 @@ /* attach channel to stream */ st->channels[i].ch = ch; st->channels[i].levelmask = levelmask; + st->channels[i].flushmask = flushmask; return L2_OK; } @@ -107,7 +109,7 @@ } /* set stream level mask */ -l2_result_t l2_stream_levels(l2_stream_t *st, unsigned int levelmask) +l2_result_t l2_stream_levels(l2_stream_t *st, unsigned int levelmask, unsigned int flushmask) { /* argument sanity check */ if (st == NULL) @@ -115,6 +117,7 @@ /* override global level mask */ st->levelmask = levelmask; + st->flushmask = flushmask; return L2_OK; } @@ -225,6 +228,9 @@ if (st->channels[i].levelmask & level) { if ((rv = l2_channel_write(st->channels[i].ch, level, st->message, len)) != L2_OK) break; + if ((st->flushmask & level) || (st->channels[i].flushmask & level)) + if ((rv = l2_channel_flush(st->channels[i].ch)) != L2_OK) + break; } } return rv; Index: ossp-pkg/l2/l2_test.c RCS File: /v/ossp/cvs/ossp-pkg/l2/l2_test.c,v rcsdiff -q -kk '-r1.18' '-r1.19' -u '/v/ossp/cvs/ossp-pkg/l2/l2_test.c,v' 2>/dev/null --- l2_test.c 2001/09/12 13:05:39 1.18 +++ l2_test.c 2001/09/12 13:50:46 1.19 @@ -131,7 +131,7 @@ if (l2_channel_open(chPrefix) != L2_OK) die("failed to open channel stack"); - if (l2_stream_channel(st, chPrefix, L2_LEVEL_UPTO(L2_LEVEL_WARNING)) != L2_OK) + if (l2_stream_channel(st, chPrefix, L2_LEVEL_UPTO(L2_LEVEL_WARNING), L2_LEVEL_NONE) != L2_OK) die("failed to attach channel stack into stream"); if ((chSyslog = l2_channel_create(&l2_handler_syslog)) == NULL) /* Syslog */ @@ -145,7 +145,7 @@ if (l2_channel_open(chSyslog) != L2_OK) die("failed to open channel stack"); - if (l2_stream_channel(st, chSyslog, L2_LEVEL_UPTO(L2_LEVEL_WARNING)) != L2_OK) + if (l2_stream_channel(st, chSyslog, L2_LEVEL_UPTO(L2_LEVEL_WARNING), L2_LEVEL_NONE) != L2_OK) die("failed to attach channel syslog into stream"); #ifdef WITH_SMTP @@ -158,11 +158,11 @@ if (l2_channel_open(chSmtp) != L2_OK) die("failed to open smtp channel"); - if (l2_stream_channel(st, chSmtp, L2_LEVEL_UPTO(L2_LEVEL_ERROR)) != L2_OK) + if (l2_stream_channel(st, chSmtp, L2_LEVEL_UPTO(L2_LEVEL_ERROR), L2_LEVEL_NONE) != L2_OK) die("failed to attach smtp channel into stream"); #endif - if (l2_stream_levels(st, L2_LEVEL_UPTO(L2_LEVEL_WARNING)) != L2_OK) + if (l2_stream_levels(st, L2_LEVEL_UPTO(L2_LEVEL_WARNING), L2_LEVEL_NONE) != L2_OK) die("failed to set global logging level"); if (l2_stream_formatter(st, 'k', formatter, NULL) != L2_OK)