OSSP CVS Repository

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

Check-in Number: 947
Date: 2001-Sep-12 10:18:19 (local)
2001-Sep-12 08:18:19 (UTC)
User:thl
Branch:
Comment: added ability to log nothing by creating/ configuring/ stacking zero channels
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/lmtp2nntp.c      1.53 -> 1.54     47 inserted, 46 deleted

ossp-pkg/lmtp2nntp/lmtp2nntp.c 1.53 -> 1.54

--- lmtp2nntp.c  2001/09/12 07:29:23     1.53
+++ lmtp2nntp.c  2001/09/12 08:18:19     1.54
@@ -298,7 +298,7 @@
     ctx->option_maxmessagesize = 8 * 1024 * 1024;
     ctx->option_waittime = -1;
     ctx->option_mailfrom = NULL;
-    ctx->option_levelmask = L2_LEVEL_UPTO(L2_LEVEL_WARNING);
+    ctx->option_levelmask = L2_LEVEL_NONE;
     ctx->l2 = NULL;
     ctx->cpBindh = NULL;
     ctx->cpBindp = NULL;
@@ -537,6 +537,10 @@
         fprintf(stderr, "%s:Error: logging failed to create stream\n", ctx->progname);
         exit(ERR_EXECUTION);
     }
+    if (l2_stream_levels(ctx->l2, L2_LEVEL_UPTO(L2_LEVEL_DEBUG)) != L2_OK) {
+        fprintf(stderr, "%s:Error: logging failed to set global logging level\n", ctx->progname);
+        exit(ERR_EXECUTION);
+    }
 
     if (l2_stream_formatter(ctx->l2, 'P', formatter_prefix, (l2_context_t *)&ctx) != L2_OK) {
         fprintf(stderr, "%s:Error: logging failed to register formatter\n", ctx->progname);
@@ -551,59 +555,56 @@
         exit(ERR_EXECUTION);
     }
     if (l2_stream_formatter(ctx->l2, 'm', formatter_errno, NULL) != L2_OK) {
-        fprintf(stderr, "%s:Error: logging failed to register dump formatter\n", ctx->progname);
-        exit(ERR_EXECUTION);
-    }
-
-    if ((chPrefix  = l2_channel_create(&l2_handler_prefix)) == NULL) {
-        fprintf(stderr, "%s:Error: logging failed to create prefix channel\n", ctx->progname);
-        exit(ERR_EXECUTION);
-    }
-    if (l2_channel_configure(chPrefix, "timefmt,timezone", "[%d-%m-%Y/%H:%M:%S] ", "local") != L2_OK) {
-        fprintf(stderr, "%s:Error: logging failed to configure prefix channel\n", ctx->progname);
+        fprintf(stderr, "%s:Error: logging failed to register errno formatter\n", ctx->progname);
         exit(ERR_EXECUTION);
     }
 
-    if ((chBuf  = l2_channel_create(&l2_handler_buffer)) == NULL) {
-        fprintf(stderr, "%s:Error: logging failed to create buffer channel\n", ctx->progname);
-        exit(ERR_EXECUTION);
-    }
-    if (l2_channel_configure(chBuf, "size", 4) != L2_OK) { //FIXME 4096
-        fprintf(stderr, "%s:Error: logging failed to configure buffer channel\n", ctx->progname);
-        exit(ERR_EXECUTION);
-    }
+    if((ctx->option_levelmask != L2_LEVEL_NONE) && (ctx->option_logfile != NULL)) {
+        if ((chPrefix  = l2_channel_create(&l2_handler_prefix)) == NULL) {
+            fprintf(stderr, "%s:Error: logging failed to create prefix channel\n", ctx->progname);
+            exit(ERR_EXECUTION);
+        }
+        if (l2_channel_configure(chPrefix, "timefmt,timezone", "%b %d %H:%M:%S ", "local") != L2_OK) {
+            fprintf(stderr, "%s:Error: logging failed to configure prefix channel\n", ctx->progname);
+            exit(ERR_EXECUTION);
+        }
 
-    if ((chFile = l2_channel_create(&l2_handler_file)) == NULL) {
-        fprintf(stderr, "%s:Error: logging failed to create file channel\n", ctx->progname);
-        exit(ERR_EXECUTION);
-    }
-    if (l2_channel_configure(chFile, "path,append,perm", ctx->option_logfile, TRUE, 0644) != L2_OK) {
-        fprintf(stderr, "%s:Error: logging failed to configure file channel\n", ctx->progname);
-        exit(ERR_EXECUTION);
-    }
+        if ((chBuf  = l2_channel_create(&l2_handler_buffer)) == NULL) {
+            fprintf(stderr, "%s:Error: logging failed to create buffer channel\n", ctx->progname);
+            exit(ERR_EXECUTION);
+        }
+        if (l2_channel_configure(chBuf, "size", 65536) != L2_OK) { //FIXME
+            fprintf(stderr, "%s:Error: logging failed to configure buffer channel\n", ctx->progname);
+            exit(ERR_EXECUTION);
+        }
 
-    if (l2_channel_stack(chFile, chBuf) != L2_OK) {
-        fprintf(stderr, "%s:Error: logging failed to stack buffer channel on top of file channel\n", ctx->progname);
-        exit(ERR_EXECUTION);
-    }
-    if (l2_channel_stack(chBuf, chPrefix) != L2_OK) {
-        fprintf(stderr, "%s:Error: logging failed to stack prefix channel on top of buffer channel\n", ctx->progname);
-        exit(ERR_EXECUTION);
-    }
+        if ((chFile = l2_channel_create(&l2_handler_file)) == NULL) {
+            fprintf(stderr, "%s:Error: logging failed to create file channel\n", ctx->progname);
+            exit(ERR_EXECUTION);
+        }
+        if (l2_channel_configure(chFile, "path,append,perm", ctx->option_logfile, TRUE, 0644) != L2_OK) {
+            fprintf(stderr, "%s:Error: logging failed to configure file channel\n", ctx->progname);
+            exit(ERR_EXECUTION);
+        }
 
-    if (l2_channel_open(chPrefix) != L2_OK) {
-        fprintf(stderr, "%s:Error: logging failed to open buffer channel\n", ctx->progname);
-        exit(ERR_EXECUTION);
-    }
+        if (l2_channel_stack(chFile, chBuf) != L2_OK) {
+            fprintf(stderr, "%s:Error: logging failed to stack buffer channel on top of file channel\n", ctx->progname);
+            exit(ERR_EXECUTION);
+        }
+        if (l2_channel_stack(chBuf, chPrefix) != L2_OK) {
+            fprintf(stderr, "%s:Error: logging failed to stack prefix channel on top of buffer channel\n", ctx->progname);
+            exit(ERR_EXECUTION);
+        }
 
-    if (l2_stream_channel(ctx->l2, chPrefix, L2_LEVEL_UPTO(L2_LEVEL_DEBUG)) != L2_OK) {
-        fprintf(stderr, "%s:Error: logging failed to attach channel into stream\n", ctx->progname);
-        exit(ERR_EXECUTION);
-    }
+        if (l2_channel_open(chPrefix) != L2_OK) {
+            fprintf(stderr, "%s:Error: logging failed to open buffer channel\n", ctx->progname);
+            exit(ERR_EXECUTION);
+        }
 
-    if (l2_stream_levels(ctx->l2, ctx->option_levelmask) != L2_OK) {
-        fprintf(stderr, "%s:Error: logging failed to set global logging level\n", ctx->progname);
-        exit(ERR_EXECUTION);
+        if (l2_stream_channel(ctx->l2, chPrefix, ctx->option_levelmask) != L2_OK) {
+            fprintf(stderr, "%s:Error: logging failed to attach channel into stream\n", ctx->progname);
+            exit(ERR_EXECUTION);
+        }
     }
 
     if (log1(ctx, NOTICE, "startup, version %s", lmtp2nntp_version.v_gnu) != L2_OK) {

CVSTrac 2.0.1