gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r22240 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r22240 - gnunet/src/util
Date: Sun, 24 Jun 2012 00:28:37 +0200

Author: grothoff
Date: 2012-06-24 00:28:37 +0200 (Sun, 24 Jun 2012)
New Revision: 22240

Modified:
   gnunet/src/util/common_logging.c
Log:
-LRN: Support [] (formatted to be pid) in logfile names:
  I needed it for mesh debugging. Wrote this patch before your log
rotation changes, and had to hastily adapt it after them, so i'm not
sure it actually works. Did some quick tests on it, and it appears to
be working, so i'll just send it to you as is, and see how it turns out.



Modified: gnunet/src/util/common_logging.c
===================================================================
--- gnunet/src/util/common_logging.c    2012-06-23 22:25:58 UTC (rev 22239)
+++ gnunet/src/util/common_logging.c    2012-06-23 22:28:37 UTC (rev 22240)
@@ -336,11 +336,22 @@
   int altlog_fd;
   int dup_return;
   FILE *altlog;
+  char *leftsquare;
   
   if (NULL == log_file_name)
     return GNUNET_SYSERR;
   if (0 == strftime (fn, sizeof (fn), log_file_name, tm))
     return GNUNET_SYSERR;
+  leftsquare = strrchr (fn, '[');
+  if ( (NULL != leftsquare) && (']' == leftsquare[1]) )
+  {
+    char *logfile_copy = GNUNET_strdup (fn);
+    logfile_copy[leftsquare - fn] = '\0';
+    logfile_copy[leftsquare - fn + 1] = '\0';
+    snprintf (fn, PATH_MAX, "%s%d%s",
+         logfile_copy, getpid (), &logfile_copy[leftsquare - fn + 2]);
+    GNUNET_free (logfile_copy);
+  }
   if (0 == strcmp (fn, last_fn))
     return GNUNET_OK; /* no change */
   log_rotate (last_fn);




reply via email to

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