aboutsummaryrefslogtreecommitdiff
path: root/src/util/common_logging.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-23 22:28:37 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-23 22:28:37 +0000
commita14f9f0fbd4f2226d8ccef8de5d42a4abc7b82fe (patch)
tree76c4d5a1d51ef161f0c8aea3ab94b5464606d02a /src/util/common_logging.c
parent4beaf8200aa658c15d2b138d1754983a7eb253e3 (diff)
downloadgnunet-a14f9f0fbd4f2226d8ccef8de5d42a4abc7b82fe.tar.gz
gnunet-a14f9f0fbd4f2226d8ccef8de5d42a4abc7b82fe.zip
-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.
Diffstat (limited to 'src/util/common_logging.c')
-rw-r--r--src/util/common_logging.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/util/common_logging.c b/src/util/common_logging.c
index 6c3dda9bc..8ba955dea 100644
--- a/src/util/common_logging.c
+++ b/src/util/common_logging.c
@@ -336,11 +336,22 @@ setup_log_file (const struct tm *tm)
336 int altlog_fd; 336 int altlog_fd;
337 int dup_return; 337 int dup_return;
338 FILE *altlog; 338 FILE *altlog;
339 char *leftsquare;
339 340
340 if (NULL == log_file_name) 341 if (NULL == log_file_name)
341 return GNUNET_SYSERR; 342 return GNUNET_SYSERR;
342 if (0 == strftime (fn, sizeof (fn), log_file_name, tm)) 343 if (0 == strftime (fn, sizeof (fn), log_file_name, tm))
343 return GNUNET_SYSERR; 344 return GNUNET_SYSERR;
345 leftsquare = strrchr (fn, '[');
346 if ( (NULL != leftsquare) && (']' == leftsquare[1]) )
347 {
348 char *logfile_copy = GNUNET_strdup (fn);
349 logfile_copy[leftsquare - fn] = '\0';
350 logfile_copy[leftsquare - fn + 1] = '\0';
351 snprintf (fn, PATH_MAX, "%s%d%s",
352 logfile_copy, getpid (), &logfile_copy[leftsquare - fn + 2]);
353 GNUNET_free (logfile_copy);
354 }
344 if (0 == strcmp (fn, last_fn)) 355 if (0 == strcmp (fn, last_fn))
345 return GNUNET_OK; /* no change */ 356 return GNUNET_OK; /* no change */
346 log_rotate (last_fn); 357 log_rotate (last_fn);