OSSP CVS Repository

ossp - Check-in [957]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 957
Date: 2001-Sep-12 15:50:46 (local)
2001-Sep-12 13:50:46 (UTC)
User:rse
Branch:
Comment: First cut for flush mask support.
Tickets:
Inspections:
Files:
ossp-pkg/l2/l2.h.in      1.5 -> 1.6     2 inserted, 2 deleted
ossp-pkg/l2/l2_p.h      1.15 -> 1.16     2 inserted, 0 deleted
ossp-pkg/l2/l2_stream.c      1.15 -> 1.16     8 inserted, 2 deleted
ossp-pkg/l2/l2_test.c      1.18 -> 1.19     4 inserted, 4 deleted

ossp-pkg/l2/l2.h.in 1.5 -> 1.6

--- 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);


ossp-pkg/l2/l2_p.h 1.15 -> 1.16

--- 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];


ossp-pkg/l2/l2_stream.c 1.15 -> 1.16

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


ossp-pkg/l2/l2_test.c 1.18 -> 1.19

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

CVSTrac 2.0.1