gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r4748 - in GNUnet: doc/man src/include src/server src/util/


From: gnunet
Subject: [GNUnet-SVN] r4748 - in GNUnet: doc/man src/include src/server src/util/boot src/util/loggers
Date: Sun, 15 Apr 2007 16:14:13 -0600 (MDT)

Author: grothoff
Date: 2007-04-15 16:14:13 -0600 (Sun, 15 Apr 2007)
New Revision: 4748

Modified:
   GNUnet/doc/man/gnunetd.1
   GNUnet/src/include/gnunet_util_error.h
   GNUnet/src/server/gnunetd.c
   GNUnet/src/server/startup.c
   GNUnet/src/util/boot/startup.c
   GNUnet/src/util/loggers/file.c
Log:
fixing Mantis 1193

Modified: GNUnet/doc/man/gnunetd.1
===================================================================
--- GNUnet/doc/man/gnunetd.1    2007-04-15 21:37:50 UTC (rev 4747)
+++ GNUnet/doc/man/gnunetd.1    2007-04-15 22:14:13 UTC (rev 4748)
@@ -17,6 +17,9 @@
 \fB\-h\fR, \fB\-\-help\fR
 print help page
 .TP
+\fB\-l\fR, \fB\-\-loud\fR
+print all log messages (to stderr).  Only works together with the \-d option.  
Also disables logging to files.
+.TP
 \fB\-L \fILOGLEVEL\fR, \fB\-\-loglevel=LOGLEVEL\fR
 change the loglevel. Possible values for LOGLEVEL are NOTHING, FATAL, ERROR, 
WARNING, INFO, STATUS and DEBUG.  Note that options in the configuration file 
take precedence over this option (the argument will be ignored in that case).
 .TP

Modified: GNUnet/src/include/gnunet_util_error.h
===================================================================
--- GNUnet/src/include/gnunet_util_error.h      2007-04-15 21:37:50 UTC (rev 
4747)
+++ GNUnet/src/include/gnunet_util_error.h      2007-04-15 22:14:13 UTC (rev 
4748)
@@ -59,15 +59,53 @@
   GE_EVENTKIND = 0x000000FF, /* bitmask */
 
   /* who should see the message? */
+  /**
+   * These messages are sent to the console / UI.
+   * Note that when running as an administrative
+   * daemon, messages tagged just as GE_USER will
+   * be discarded.
+   */
   GE_USER      = 0x01000000, /* current user, if possible */
+  /**
+   * These messages are sent to the logfile for the
+   * administrator.  Note that normal users may not
+   * always look there.
+   */
   GE_ADMIN     = 0x02000000, /* system administrator */
+  /**
+   * These messages are usually not logged or given
+   * to the user.  They can be obtained when the tool
+   * is run in debug mode.
+   */
   GE_DEVELOPER = 0x04000000, /* GNUnet developers (bug!) */
+  /**
+   * Mask for the type of user that should see the
+   * message.
+   */
   GE_USERKIND  = 0x0F000000, /* bitmask */
 
   /* how event should be routed */
+  /**
+   * The message should only be shown upon specific
+   * request.
+   */
   GE_REQUEST   = 0x20000000, /* display on request only (i.e. low-priority 
log, user demands verbose events) */
+  /**
+   * This type of message is not urgent and is likely
+   * to occur in bulk.  Suitable for logging to a file
+   * or in a generic, scrolling message window.
+   */
   GE_BULK      = 0x40000000, /* display in bulk output (i.e. log-file, scroll 
window, console) */
+  /**
+   * This is a message that is urgent and should be
+   * communicated as soon as possible.  Sending an
+   * e-mail alert or opening a pop-up window maybe
+   * appropriate.
+   */
   GE_IMMEDIATE = 0x80000000, /* display immediately (i.e. pop-up, e-mail) */
+  /**
+   * Mask for the routing type.
+   */
   GE_ROUTEKIND = 0xF0000000, /* bitmask */
   GE_ALL       = 0xFFFFFFFF,
   GE_INVALID   = 0x08000000, /* unused bit */
@@ -87,7 +125,7 @@
 void GE_setDefaultContext(struct GE_Context * ctx);
 
 /**
- * User-defined handler for Log events.
+ * User-defined handler for log events.
  */
 typedef void (*GE_LogHandler)(void * ctx,
                              GE_KIND kind,

Modified: GNUnet/src/server/gnunetd.c
===================================================================
--- GNUnet/src/server/gnunetd.c 2007-04-15 21:37:50 UTC (rev 4747)
+++ GNUnet/src/server/gnunetd.c 2007-04-15 22:14:13 UTC (rev 4748)
@@ -50,7 +50,7 @@
 
 static int debug_flag;
 
-static int quiet_flag;
+static int loud_flag;
 
 #ifndef WINDOWS
 /**
@@ -212,9 +212,9 @@
   { 'p', "padding-disable", "YES/NO",
     gettext_noop("disable padding with random data (experimental)"), 0,
     &gnunet_getopt_configure_set_option, "GNUNETD-EXPERIMENTAL:PADDING" },
-  { 'q', "quiet", NULL,
-    gettext_noop("run in quiet mode"),
-    0, &gnunet_getopt_configure_set_one, &quiet_flag },
+  { 'l', "loud", NULL,
+    gettext_noop("print all log messages to the console (only works together 
with -d)"),
+    0, &gnunet_getopt_configure_set_one, &loud_flag },
 #ifndef MINGW
   { 'u', "user", "USERNAME",
     gettext_noop("specify username as which gnunetd should run"), 1,
@@ -249,15 +249,13 @@
     GNUNET_fini(ectx, cfg);
     return 1;
   }
-  if (YES == debug_flag) {
-    if (quiet_flag == 0) {
-      ectx = GE_create_context_multiplexer(ectx,
-                                          GE_create_context_stderr(NO,
-                                                                   GE_USERKIND 
|
-                                                                   
GE_EVENTKIND |
-                                                                   GE_BULK |
-                                                                   
GE_IMMEDIATE));
-    }
+  if ( (YES == debug_flag) &&
+       (loud_flag == 1) ) {
+    GE_setDefaultContext(NULL);
+    GE_free_context(ectx);
+    ectx = GE_create_context_stderr(YES,
+                                   GE_ALL);
+    GE_setDefaultContext(ectx);   
   }
   setFdLimit(ectx, cfg);
   if (OK != checkUpToDate(ectx,

Modified: GNUnet/src/server/startup.c
===================================================================
--- GNUnet/src/server/startup.c 2007-04-15 21:37:50 UTC (rev 4747)
+++ GNUnet/src/server/startup.c 2007-04-15 22:14:13 UTC (rev 4748)
@@ -282,7 +282,7 @@
   if (0 != ACCESS(fn, mode)) {
     GE_LOG(ectx,
           GE_FATAL | GE_USER | GE_ADMIN | GE_IMMEDIATE,
-          _("Insufficient access permissions for `%s': %s"),
+          _("Insufficient access permissions for `%s': %s\n"),
           fn,
           STRERROR(errno));
     FREE(fn);

Modified: GNUnet/src/util/boot/startup.c
===================================================================
--- GNUnet/src/util/boot/startup.c      2007-04-15 21:37:50 UTC (rev 4747)
+++ GNUnet/src/util/boot/startup.c      2007-04-15 22:14:13 UTC (rev 4748)
@@ -30,10 +30,6 @@
 #include "gnunet_util_error_loggers.h"
 #include "platform.h"
 
-#define DO_REQUEST NO
-
-#define DO_DEVELOPER NO
-
 static GE_KIND
 convertLogLevel(const char * level) {
   GE_KIND ret;
@@ -114,15 +110,9 @@
   }
   FREE(admin_log_file);
   if (ull != 0) {
-    tetx = GE_create_context_stderr(NO,
+    tetx = GE_create_context_stderr(YES,
                                    ull
                                    | GE_USERKIND
-#if DO_REQUEST
-                                   | GE_REQUEST
-#endif
-#if DO_DEVELOPER
-                                    | GE_DEVELOPER | GE_DEBUG | GE_ADMIN
-#endif
                                    | GE_BULK
                                    | GE_IMMEDIATE);
     if (nctx == NULL)
@@ -167,7 +157,7 @@
 #endif
   /* during startup, log all warnings and higher
      for anybody to stderr */
-  *ectx = GE_create_context_stderr(NO,
+  *ectx = GE_create_context_stderr(YES,
                                   GE_WARNING | GE_ERROR | GE_FATAL |
                                   GE_USER | GE_ADMIN | GE_DEVELOPER |
                                   GE_IMMEDIATE | GE_BULK);
@@ -211,6 +201,7 @@
 void GNUNET_fini(struct GE_Context * ectx,
                 struct GC_Configuration * cfg) {
   GC_free(cfg);
+  GE_setDefaultContext(NULL);
   GE_free_context(ectx);
 }
                

Modified: GNUnet/src/util/loggers/file.c
===================================================================
--- GNUnet/src/util/loggers/file.c      2007-04-15 21:37:50 UTC (rev 4747)
+++ GNUnet/src/util/loggers/file.c      2007-04-15 22:14:13 UTC (rev 4748)
@@ -80,6 +80,12 @@
   int yday;
 
   /**
+   * Is this the first time we log anything for this
+   * process?  Used with log rotation to delete old logs.
+   */
+  int first_start;
+
+  /**
    * When did we start the current logfile?
    */
   TIME_T logstart;
@@ -209,8 +215,10 @@
   if (fctx->logrotate) {
     name = getLogFileName(fctx->ectx,
                          fctx->basename);
-    if (0 != strcmp(name,
-                   fctx->filename)) {
+    if ( (fctx->first_start == YES) ||
+        (0 != strcmp(name,
+                     fctx->filename)) ) {
+      fctx->first_start = NO;
       fclose(fctx->handle);
       fctx->handle = FOPEN(name, "a+");
       FREE(fctx->filename);
@@ -231,8 +239,8 @@
   if (fctx->logdate) {
     ret = fprintf(fctx->handle,
                  "%s: %s %s",
+                 date,
                  GE_kindToString(kind & GE_EVENTKIND),
-                 date,
                  msg);
   } else {
     ret = fprintf(fctx->handle,
@@ -302,6 +310,7 @@
     return NULL; /* ERROR! */
   }
   fctx = MALLOC(sizeof(FileContext));
+  fctx->first_start = YES;
   fctx->ectx = ectx;
   fctx->logdate = logDate;
   fctx->logrotate = logrotate;
@@ -336,6 +345,7 @@
   fctx->filename = NULL;
   fctx->basename = NULL;
   fctx->logstart = 0;
+  fctx->first_start = NO;
   fctx->lock = MUTEX_CREATE(YES);
   return GE_create_context_callback(mask,
                                    &filelogger,
@@ -359,6 +369,7 @@
   fctx->ectx = NULL;
   fctx->logdate = logDate;
   fctx->logrotate = 0;
+  fctx->first_start = NO;
   fctx->handle = stdout;
   fctx->filename = NULL;
   fctx->basename = NULL;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]