From 0a8077f0d64daeb6e1510ae4cf52045d07a84831 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 26 Apr 2009 09:43:06 +0200 Subject: [PATCH] Remove time in weechat.log file when dumping data (crash or user is asking dump) --- src/core/wee-command.c | 3 +++ src/core/wee-debug.c | 1 + src/core/wee-log.c | 30 +++++++++++++++++++----------- src/core/wee-log.h | 1 + 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 6beb4c185..778274489 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -831,7 +831,10 @@ command_debug (void *data, struct t_gui_buffer *buffer, if (string_strcasecmp (argv[1], "dump") == 0) { + log_printf ("Dump request for WeeChat core and plugins"); + weechat_log_use_time = 0; hook_signal_send ("debug_dump", WEECHAT_HOOK_SIGNAL_STRING, NULL); + weechat_log_use_time = 1; } else if (string_strcasecmp (argv[1], "buffer") == 0) { diff --git a/src/core/wee-debug.c b/src/core/wee-debug.c index 573382c5e..edf92372f 100644 --- a/src/core/wee-debug.c +++ b/src/core/wee-debug.c @@ -64,6 +64,7 @@ debug_dump (int crash) { debug_dump_active = 1; log_printf ("Very bad, WeeChat is crashing (SIGSEGV received)..."); + weechat_log_use_time = 0; } log_printf (""); diff --git a/src/core/wee-log.c b/src/core/wee-log.c index 28d404c05..bedc16c86 100644 --- a/src/core/wee-log.c +++ b/src/core/wee-log.c @@ -38,11 +38,14 @@ #include "weechat.h" #include "wee-log.h" +#include "wee-debug.h" #include "wee-string.h" char *weechat_log_filename = NULL; /* log name (~/.weechat/weechat.log) */ FILE *weechat_log_file = NULL; /* WeeChat log file */ +int weechat_log_use_time = 1; /* 0 to temporary disable time in log, */ + /* for example when dumping data */ /* @@ -142,18 +145,23 @@ log_printf (const char *message, ...) ptr_buffer[0] = '.'; ptr_buffer++; } - - seconds = time (NULL); - date_tmp = localtime (&seconds); - if (date_tmp) - string_iconv_fprintf (weechat_log_file, - "[%04d-%02d-%02d %02d:%02d:%02d] %s\n", - date_tmp->tm_year + 1900, date_tmp->tm_mon + 1, - date_tmp->tm_mday, date_tmp->tm_hour, - date_tmp->tm_min, date_tmp->tm_sec, - buffer); - else + + if (!weechat_log_use_time) string_iconv_fprintf (weechat_log_file, "%s\n", buffer); + else + { + seconds = time (NULL); + date_tmp = localtime (&seconds); + if (date_tmp) + string_iconv_fprintf (weechat_log_file, + "[%04d-%02d-%02d %02d:%02d:%02d] %s\n", + date_tmp->tm_year + 1900, date_tmp->tm_mon + 1, + date_tmp->tm_mday, date_tmp->tm_hour, + date_tmp->tm_min, date_tmp->tm_sec, + buffer); + else + string_iconv_fprintf (weechat_log_file, "%s\n", buffer); + } fflush (weechat_log_file); } diff --git a/src/core/wee-log.h b/src/core/wee-log.h index 4c90cd0ec..17abee314 100644 --- a/src/core/wee-log.h +++ b/src/core/wee-log.h @@ -22,6 +22,7 @@ extern char *weechat_log_filename; extern FILE *weechat_log_file; +extern int weechat_log_use_time; extern void log_init (); extern void log_close ();