OSSP CVS Repository

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

Check-in Number: 837
Date: 2001-Sep-04 16:17:11 (local)
2001-Sep-04 14:17:11 (UTC)
User:ms
Branch:
Comment: Bugfixes and new format testing.
Tickets:
Inspections:
Files:
ossp-pkg/l2/l2_stream.c      1.8 -> 1.9     1 inserted, 1 deleted
ossp-pkg/l2/l2_test.c      1.6 -> 1.7     22 inserted, 1 deleted

ossp-pkg/l2/l2_stream.c 1.8 -> 1.9

--- l2_stream.c  2001/09/04 13:52:59     1.8
+++ l2_stream.c  2001/09/04 14:17:11     1.9
@@ -65,7 +65,7 @@
 {
     int i;
 
-    if (st == NULL || id == '\0' || cb != NULL)
+    if (st == NULL || id == '\0' || cb == NULL)
         return L2_ERROR;
     for (i = 0; i < L2_MAX_FORMATTERS && st->formatters[i].cb != NULL; i++)
         ;


ossp-pkg/l2/l2_test.c 1.6 -> 1.7

--- l2_test.c    2001/09/03 13:43:33     1.6
+++ l2_test.c    2001/09/04 14:17:11     1.7
@@ -42,6 +42,24 @@
     exit(1);
 }
 
+l2_result_t formatter(
+    l2_context_t *ctx,     
+    const char    id,     
+    const char   *param,  
+    char         *bufptr, 
+    size_t        bufsize,
+    size_t       *buflen, 
+    va_list      *ap 
+)
+{
+    int i;
+    
+    i = va_arg(*ap, int);
+    sprintf(bufptr, "[%d/%s]", i, param);
+    *buflen = strlen(bufptr);
+    return L2_OK;
+}
+
 int main(int argc, char *argv[])
 {
     l2_channel_t *chBuf;
@@ -79,7 +97,10 @@
     if (l2_stream_levels(st, L2_LEVEL_UPTO(L2_LEVEL_WARNING), NULL) != L2_OK)
         die("failed to set global logging level");
     
-    if (l2_stream_log(st, L2_LEVEL_PANIC, "test %s", "foo") != L2_OK)
+    if (l2_stream_formatter(st, 'k', formatter, NULL) != L2_OK)
+        die("failed to configure formatter for %%x");
+
+    if (l2_stream_log(st, L2_LEVEL_PANIC, "test %s %{foo}k", "foo", 12345) != L2_OK)
         die("failed to log message to stream");
 
     if (l2_stream_destroy(st) != L2_OK)

CVSTrac 2.0.1