OSSP CVS Repository

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

Check-in Number: 1174
Date: 2001-Oct-12 15:23:52 (local)
2001-Oct-12 13:23:52 (UTC)
User:thl
Branch:
Comment: added -V veryverbose (unbuffered logging) option
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/lmtp2nntp.c      1.88 -> 1.89     37 inserted, 16 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp.pod      1.30 -> 1.31     6 inserted, 1 deleted

ossp-pkg/lmtp2nntp/lmtp2nntp.c 1.88 -> 1.89

--- lmtp2nntp.c  2001/10/12 12:26:26     1.88
+++ lmtp2nntp.c  2001/10/12 13:23:52     1.89
@@ -157,6 +157,7 @@
     int             option_daemon;
     int             option_aclc;
     struct acl      option_acl[MAXACLS];
+    int             option_veryverbose;
     int             option_childsmax;
     int             active_childs;
     l2_stream_t    *l2;
@@ -211,6 +212,7 @@
             "[-D] "
             "[-K] "
             "[-P pidfile] "
+            "[-V] "
             "[-a addr/mask[,addr/mask[,...]] "
             "[-b addr[:port]|-|path[:perms]] "
             "[-c addr[:port]] "
@@ -356,7 +358,7 @@
                 log2(ctx, NOTICE, "caught signal %d - child [%ld] terminated", sig, (long)pid);
                 return;
             case SIGUSR1:
-                log1(ctx, NOTICE, "caught signal %d - flush logging buffer", sig);
+                log1(ctx, NOTICE, "caught signal %d - flush logging stream", sig);
                 l2_stream_flush(ctx->l2);
                 return;
             case SIGHUP:
@@ -439,6 +441,7 @@
     ctx->option_killflag = FALSE;
     ctx->option_uid = getuid();
     ctx->option_daemon = FALSE;
+    ctx->option_veryverbose = FALSE;
     ctx->option_childsmax = 10;
     ctx->active_childs = 0;
     ctx->l2 = NULL;
@@ -482,7 +485,7 @@
      */
 
     /* read in the arguments */
-    while ((i = getopt(argc, argv, "C:DKP:a:b:c:d:g:l:m:n:o:s:t:u:v")) != -1) {
+    while ((i = getopt(argc, argv, "C:DKP:Va:b:c:d:g:l:m:n:o:s:t:u:v")) != -1) {
         switch (i) {
             case 'C': /*POD [B<-C> I<childsmax>] */
                 ctx->option_childsmax = atoi(optarg);
@@ -500,6 +503,9 @@
             case 'P': /*POD [B<-P> I<pidfile>] */
                 ctx->option_pidfile = strdup(optarg);
                 break;
+            case 'V': /*POD [B<-V>] */
+                ctx->option_veryverbose = TRUE;
+                break;
             case 'a': /*POD [B<-a> I<addr>/I<mask>[,I<addr>/I<mask>[,...]] */
                 if (argz_create_sep(optarg, ',', &azACL, &asACL) != 0)
                     CU(ERR_EXECUTION);
@@ -945,14 +951,18 @@
             CU(ERR_EXECUTION);
         }
 
-        if ((chBuf  = l2_channel_create(&l2_handler_buffer)) == NULL) {
-            fprintf(stderr, "%s:Error: logging failed to create buffer channel\n", ctx->progname);
-            CU(ERR_EXECUTION);
-        }
-        if (l2_channel_configure(chBuf, "size", 65536) != L2_OK) {
-            fprintf(stderr, "%s:Error: logging failed to configure buffer channel\n", ctx->progname);
-            CU(ERR_EXECUTION);
+        if (!ctx->option_veryverbose) {
+            if ((chBuf  = l2_channel_create(&l2_handler_buffer)) == NULL) {
+                fprintf(stderr, "%s:Error: logging failed to create buffer channel\n", ctx->progname);
+                CU(ERR_EXECUTION);
+            }
+            if (l2_channel_configure(chBuf, "size", 65536) != L2_OK) {
+                fprintf(stderr, "%s:Error: logging failed to configure buffer channel\n", ctx->progname);
+                CU(ERR_EXECUTION);
+            }
         }
+        else
+            chBuf = NULL;
 
         if ((chFile = l2_channel_create(&l2_handler_file)) == NULL) {
             fprintf(stderr, "%s:Error: logging failed to create file channel\n", ctx->progname);
@@ -963,13 +973,21 @@
             CU(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);
-            CU(ERR_EXECUTION);
+        if (!ctx->option_veryverbose) {
+            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);
+                CU(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);
+                CU(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);
-            CU(ERR_EXECUTION);
+        else {
+            if (l2_channel_stack(chFile, chPrefix) != L2_OK) {
+                fprintf(stderr, "%s:Error: logging failed to stack prefix channel on top of buffer channel\n", ctx->progname);
+                CU(ERR_EXECUTION);
+            }
         }
 
         if (l2_channel_open(chPrefix) != L2_OK) {
@@ -991,6 +1009,9 @@
      * should not be used in the remainder of the code
      */
 
+    if (ctx->option_veryverbose)
+        log0(ctx, NOTICE, "logging very verbose (unbuffered)");
+
     if ((ctx->option_pidfile != NULL) && ctx->option_killflag) {
         if ((fd = fopen(ctx->option_pidfile, "r")) == NULL)
             log1(ctx, ERROR, "cannot open pidfile \"%s\" for reading %m", ctx->option_pidfile);
@@ -1167,7 +1188,7 @@
             log1(ctx, NOTICE, "startup new child process, parent pid[%d]", getppid());
 
             /* child must close listening socket */
-            sa_destroy(ctx->saAltio); 
+            sa_destroy(ctx->saAltio);
             
             /* initialize LMTP context */
             lmtp_io.ctx    = ctx;


ossp-pkg/lmtp2nntp/lmtp2nntp.pod 1.30 -> 1.31

--- lmtp2nntp.pod        2001/10/12 12:26:26     1.30
+++ lmtp2nntp.pod        2001/10/12 13:23:52     1.31
@@ -37,6 +37,7 @@
 [B<-D>]
 [B<-K>]
 [B<-P> I<pidfile>]
+[B<-V>]
 [B<-a> I<addr>/I<mask>[,I<addr>/I<mask>[,...]]
 [B<-b> I<addr>[I<:port>]|C<->|I<path>[:perms]]
 [B<-c> I<addr>[I<:port>]]
@@ -89,6 +90,10 @@
 must be taken when using relative path names as daemonizing changes the
 current working directory to '/'.
 
+=item B<-V>
+
+Very verbose logging. This means logging is unbuffered.
+
 =item B<-a> I<addr>/I<mask>[,I<addr>/I<mask>[,...]] (LMTP daemon ACL)
 
 Access control list specifying TCP INET addresses and masks where incoming
@@ -223,7 +228,7 @@
 
 =head1 SIGNALS
 
-Sending a USR1 signal to the program will flush the logging buffer.
+Sending a USR1 signal to the program will flush the logging stream.
 
 =head1 DIAGNOSTICS
 

CVSTrac 2.0.1