summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--doc/de/autogen/user/logger_options.txt5
-rw-r--r--doc/en/autogen/user/logger_options.txt5
-rw-r--r--doc/fr/autogen/user/logger_options.txt5
-rw-r--r--doc/it/autogen/user/logger_options.txt5
-rw-r--r--po/cs.po7
-rw-r--r--po/de.po7
-rw-r--r--po/es.po7
-rw-r--r--po/fr.po12
-rw-r--r--po/hu.po7
-rw-r--r--po/it.po7
-rw-r--r--po/pl.po7
-rw-r--r--po/pt_BR.po7
-rw-r--r--po/ru.po7
-rw-r--r--po/weechat.pot7
-rw-r--r--src/plugins/logger/logger-buffer.c3
-rw-r--r--src/plugins/logger/logger-buffer.h1
-rw-r--r--src/plugins/logger/logger-config.c53
-rw-r--r--src/plugins/logger/logger.c50
-rw-r--r--src/plugins/logger/logger.h3
20 files changed, 195 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 8bd501f5f..32f60eff9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,7 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
-v0.3.6-dev, 2011-05-16
+v0.3.6-dev, 2011-05-18
Version 0.3.6 (under dev!)
@@ -11,6 +11,7 @@ Version 0.3.6 (under dev!)
/window scroll_horiz) (task #11112)
* api: fix bug with function config_set_desc_plugin (use immediately
description for option when function is called)
+* logger: add option logger.file.flush_delay (task #11118)
Version 0.3.5 (2011-05-15)
--------------------------
diff --git a/doc/de/autogen/user/logger_options.txt b/doc/de/autogen/user/logger_options.txt
index 2b3c91a4e..45b0d6e22 100644
--- a/doc/de/autogen/user/logger_options.txt
+++ b/doc/de/autogen/user/logger_options.txt
@@ -3,6 +3,11 @@
** Typ: boolesch
** Werte: on, off (Standardwert: `on`)
+* *logger.file.flush_delay*
+** Beschreibung: `number of seconds between flush of log files (0 = write in log files immediately for each line printed)`
+** Typ: integer
+** Werte: 0 .. 3600 (Standardwert: `120`)
+
* *logger.file.info_lines*
** Beschreibung: `Fügt eine Information in die Protokoll-Datei ein, falls die Protokollierung gestartet oder beendet wird`
** Typ: boolesch
diff --git a/doc/en/autogen/user/logger_options.txt b/doc/en/autogen/user/logger_options.txt
index a3c536aaa..f00828f39 100644
--- a/doc/en/autogen/user/logger_options.txt
+++ b/doc/en/autogen/user/logger_options.txt
@@ -3,6 +3,11 @@
** type: boolean
** values: on, off (default value: `on`)
+* *logger.file.flush_delay*
+** description: `number of seconds between flush of log files (0 = write in log files immediately for each line printed)`
+** type: integer
+** values: 0 .. 3600 (default value: `120`)
+
* *logger.file.info_lines*
** description: `write information line in log file when log starts or ends for a buffer`
** type: boolean
diff --git a/doc/fr/autogen/user/logger_options.txt b/doc/fr/autogen/user/logger_options.txt
index 7d37d1bb1..66cd2f5a3 100644
--- a/doc/fr/autogen/user/logger_options.txt
+++ b/doc/fr/autogen/user/logger_options.txt
@@ -3,6 +3,11 @@
** type: booléen
** valeurs: on, off (valeur par défaut: `on`)
+* *logger.file.flush_delay*
+** description: `nombre de secondes entre les "flush" (écriture) dans les fichiers de log (0 = écrire immédiatement dans les fichiers de log pour chaque ligne affichée)`
+** type: entier
+** valeurs: 0 .. 3600 (valeur par défaut: `120`)
+
* *logger.file.info_lines*
** description: `écrire une ligne d'information dans le fichier log quand le log démarre ou se termine pour un tampon`
** type: booléen
diff --git a/doc/it/autogen/user/logger_options.txt b/doc/it/autogen/user/logger_options.txt
index dde4fa322..87ac292d4 100644
--- a/doc/it/autogen/user/logger_options.txt
+++ b/doc/it/autogen/user/logger_options.txt
@@ -3,6 +3,11 @@
** tipo: bool
** valori: on, off (valore predefinito: `on`)
+* *logger.file.flush_delay*
+** descrizione: `number of seconds between flush of log files (0 = write in log files immediately for each line printed)`
+** tipo: intero
+** valori: 0 .. 3600 (valore predefinito: `120`)
+
* *logger.file.info_lines*
** descrizione: `scrive una riga informativa nel file di log quando il log inizia o termina per un buffer`
** tipo: bool
diff --git a/po/cs.po b/po/cs.po
index cd2648d93..d38048e7e 100644
--- a/po/cs.po
+++ b/po/cs.po
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.6-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2011-05-16 11:54+0200\n"
+"POT-Creation-Date: 2011-05-18 12:03+0200\n"
"PO-Revision-Date: 2011-05-15 10:51+0200\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -6347,6 +6347,11 @@ msgstr ""
"automaticky ukládat obsah bufferu do souboru (pokud je zapnuto logování "
"bufferu)"
+msgid ""
+"number of seconds between flush of log files (0 = write in log files "
+"immediately for each line printed)"
+msgstr ""
+
msgid "use only lower case for log filenames"
msgstr "používat pouze malé písmena ve jménech logovacích souborů"
diff --git a/po/de.po b/po/de.po
index 42b99a5f8..192f22799 100644
--- a/po/de.po
+++ b/po/de.po
@@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.6-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2011-05-16 11:54+0200\n"
+"POT-Creation-Date: 2011-05-18 12:03+0200\n"
"PO-Revision-Date: 2011-05-15 10:51+0200\n"
"Last-Translator: Nils G.\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -6624,6 +6624,11 @@ msgstr ""
"Speichert automatisch den Inhalt eines Buffers in eine Datei (sofern das "
"Protokollieren für den Buffer nicht deaktiviert sein sollte)"
+msgid ""
+"number of seconds between flush of log files (0 = write in log files "
+"immediately for each line printed)"
+msgstr ""
+
msgid "use only lower case for log filenames"
msgstr "Benutze ausschließlich Kleinschreibung für Protokoll-Dateien"
diff --git a/po/es.po b/po/es.po
index 71e45f68d..5eafef91a 100644
--- a/po/es.po
+++ b/po/es.po
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.6-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2011-05-16 11:54+0200\n"
+"POT-Creation-Date: 2011-05-18 12:03+0200\n"
"PO-Revision-Date: 2011-05-15 10:51+0200\n"
"Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -6450,6 +6450,11 @@ msgstr ""
"automáticamente guardar el contenido del buffer a los archivos (al menos que "
"el buffer desactive el registro)"
+msgid ""
+"number of seconds between flush of log files (0 = write in log files "
+"immediately for each line printed)"
+msgstr ""
+
msgid "use only lower case for log filenames"
msgstr "usar solamente minúsculas para el nombre de los archivos"
diff --git a/po/fr.po b/po/fr.po
index 15e45bb8a..fedbd82e4 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -21,8 +21,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.6-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2011-05-16 11:54+0200\n"
-"PO-Revision-Date: 2011-05-16 11:54+0200\n"
+"POT-Creation-Date: 2011-05-18 12:03+0200\n"
+"PO-Revision-Date: 2011-05-18 12:03+0200\n"
"Last-Translator: Sebastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: French\n"
@@ -6484,6 +6484,14 @@ msgstr ""
"sauve automatiquement le contenu des tampons dans des fichiers (sauf si un "
"tampon désactive le log)"
+msgid ""
+"number of seconds between flush of log files (0 = write in log files "
+"immediately for each line printed)"
+msgstr ""
+"nombre de secondes entre les \"flush\" (écriture) dans les fichiers de log "
+"(0 = écrire immédiatement dans les fichiers de log pour chaque ligne "
+"affichée)"
+
msgid "use only lower case for log filenames"
msgstr "utiliser seulement des minuscules dans le nom des fichiers de log"
diff --git a/po/hu.po b/po/hu.po
index 64d1bb564..a91ba39a8 100644
--- a/po/hu.po
+++ b/po/hu.po
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.6-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2011-05-16 11:54+0200\n"
+"POT-Creation-Date: 2011-05-18 12:03+0200\n"
"PO-Revision-Date: 2011-05-15 10:51+0200\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -5934,6 +5934,11 @@ msgid ""
"automatically save content of buffers to files (unless a buffer disables log)"
msgstr ""
+msgid ""
+"number of seconds between flush of log files (0 = write in log files "
+"immediately for each line printed)"
+msgstr ""
+
msgid "use only lower case for log filenames"
msgstr ""
diff --git a/po/it.po b/po/it.po
index a476bbcc9..7271cbc7c 100644
--- a/po/it.po
+++ b/po/it.po
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.6-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2011-05-16 11:54+0200\n"
+"POT-Creation-Date: 2011-05-18 12:03+0200\n"
"PO-Revision-Date: 2011-05-15 10:52+0200\n"
"Last-Translator: Marco Paolone <marcopaolone@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -6442,6 +6442,11 @@ msgstr ""
"salva automaticamente il contenuto dei buffer su file (a meno che un buffer "
"disabiliti il log)"
+msgid ""
+"number of seconds between flush of log files (0 = write in log files "
+"immediately for each line printed)"
+msgstr ""
+
msgid "use only lower case for log filenames"
msgstr "utilizzare solo lettere minuscole per i nomi dei file di log"
diff --git a/po/pl.po b/po/pl.po
index 2faa71a56..da9716cb5 100644
--- a/po/pl.po
+++ b/po/pl.po
@@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.6-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2011-05-16 11:54+0200\n"
+"POT-Creation-Date: 2011-05-18 12:03+0200\n"
"PO-Revision-Date: 2011-05-15 10:52+0200\n"
"Last-Translator: Krzysztof Koroscik <soltys@szluug.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -6391,6 +6391,11 @@ msgstr ""
"automatycznie zapisuj zawartość buforów do plików (chyba, że bufor ma "
"wyłączone logowanie)"
+msgid ""
+"number of seconds between flush of log files (0 = write in log files "
+"immediately for each line printed)"
+msgstr ""
+
msgid "use only lower case for log filenames"
msgstr "używaj tylko małych liter dla nazw plików z logami"
diff --git a/po/pt_BR.po b/po/pt_BR.po
index 84d5412e7..f4aa8691c 100644
--- a/po/pt_BR.po
+++ b/po/pt_BR.po
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.6-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2011-05-16 11:54+0200\n"
+"POT-Creation-Date: 2011-05-18 12:03+0200\n"
"PO-Revision-Date: 2011-05-15 10:52+0200\n"
"Last-Translator: Ivan Sichmann Freitas <ivansichfreitas@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -5767,6 +5767,11 @@ msgid ""
"automatically save content of buffers to files (unless a buffer disables log)"
msgstr ""
+msgid ""
+"number of seconds between flush of log files (0 = write in log files "
+"immediately for each line printed)"
+msgstr ""
+
msgid "use only lower case for log filenames"
msgstr ""
diff --git a/po/ru.po b/po/ru.po
index 71e15cf8a..bec90017a 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.3.6-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2011-05-16 11:54+0200\n"
+"POT-Creation-Date: 2011-05-18 12:03+0200\n"
"PO-Revision-Date: 2011-05-15 10:52+0200\n"
"Last-Translator: Pavel Shevchuk <stlwrt@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -5949,6 +5949,11 @@ msgid ""
"automatically save content of buffers to files (unless a buffer disables log)"
msgstr ""
+msgid ""
+"number of seconds between flush of log files (0 = write in log files "
+"immediately for each line printed)"
+msgstr ""
+
msgid "use only lower case for log filenames"
msgstr ""
diff --git a/po/weechat.pot b/po/weechat.pot
index 80710089b..dec64f918 100644
--- a/po/weechat.pot
+++ b/po/weechat.pot
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
-"POT-Creation-Date: 2011-05-16 11:54+0200\n"
+"POT-Creation-Date: 2011-05-18 12:03+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -5157,6 +5157,11 @@ msgid ""
"automatically save content of buffers to files (unless a buffer disables log)"
msgstr ""
+msgid ""
+"number of seconds between flush of log files (0 = write in log files "
+"immediately for each line printed)"
+msgstr ""
+
msgid "use only lower case for log filenames"
msgstr ""
diff --git a/src/plugins/logger/logger-buffer.c b/src/plugins/logger/logger-buffer.c
index 9f023076b..8f8ef0616 100644
--- a/src/plugins/logger/logger-buffer.c
+++ b/src/plugins/logger/logger-buffer.c
@@ -93,6 +93,7 @@ logger_buffer_add (struct t_gui_buffer *buffer, int log_level)
new_logger_buffer->log_enabled = 1;
new_logger_buffer->log_level = log_level;
new_logger_buffer->write_start_info_line = 1;
+ new_logger_buffer->flush_needed = 0;
new_logger_buffer->prev_buffer = last_logger_buffer;
new_logger_buffer->next_buffer = NULL;
@@ -228,6 +229,8 @@ logger_buffer_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "write_start_info_line", logger_buffer->write_start_info_line))
return 0;
+ if (!weechat_infolist_new_var_integer (ptr_item, "flush_needed", logger_buffer->flush_needed))
+ return 0;
return 1;
}
diff --git a/src/plugins/logger/logger-buffer.h b/src/plugins/logger/logger-buffer.h
index 1255a3d73..293d85757 100644
--- a/src/plugins/logger/logger-buffer.h
+++ b/src/plugins/logger/logger-buffer.h
@@ -31,6 +31,7 @@ struct t_logger_buffer
int log_level; /* log level (0..9) */
int write_start_info_line; /* 1 if start info line must be */
/* written in file */
+ int flush_needed; /* flush needed? */
struct t_logger_buffer *prev_buffer; /* link to previous buffer */
struct t_logger_buffer *next_buffer; /* link to next buffer */
};
diff --git a/src/plugins/logger/logger-config.c b/src/plugins/logger/logger-config.c
index c7d67bda0..f6ec61b83 100644
--- a/src/plugins/logger/logger-config.c
+++ b/src/plugins/logger/logger-config.c
@@ -42,6 +42,7 @@ struct t_config_option *logger_config_look_backlog;
/* logger config, file section */
struct t_config_option *logger_config_file_auto_log;
+struct t_config_option *logger_config_file_flush_delay;
struct t_config_option *logger_config_file_name_lower_case;
struct t_config_option *logger_config_file_path;
struct t_config_option *logger_config_file_mask;
@@ -69,6 +70,49 @@ logger_config_change_file_option_restart_log (void *data,
}
/*
+ * logger_config_flush_delay_change: called when flush delay is changed
+ */
+
+void
+logger_config_flush_delay_change (void *data,
+ struct t_config_option *option)
+{
+ /* make C compiler happy */
+ (void) data;
+ (void) option;
+
+ if (logger_config_loading)
+ return;
+
+ if (logger_timer)
+ {
+ if (weechat_logger_plugin->debug)
+ {
+ weechat_printf_tags (NULL,
+ "no_log",
+ "%s: stopping timer", LOGGER_PLUGIN_NAME);
+ }
+ weechat_unhook (logger_timer);
+ logger_timer = NULL;
+ }
+
+ if (weechat_config_integer (logger_config_file_flush_delay) > 0)
+ {
+ if (weechat_logger_plugin->debug)
+ {
+ weechat_printf_tags (NULL,
+ "no_log",
+ "%s: starting timer (interval: %d seconds)",
+ LOGGER_PLUGIN_NAME,
+ weechat_config_integer (logger_config_file_flush_delay));
+ }
+ logger_timer = weechat_hook_timer (weechat_config_integer (logger_config_file_flush_delay) * 1000,
+ 0, 0,
+ &logger_timer_cb, NULL);
+ }
+}
+
+/*
* logger_config_level_change: called when a level option is changed
*/
@@ -352,6 +396,13 @@ logger_config_init ()
N_("automatically save content of buffers to files (unless a buffer "
"disables log)"),
NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ logger_config_file_flush_delay = weechat_config_new_option (
+ logger_config_file, ptr_section,
+ "flush_delay", "integer",
+ N_("number of seconds between flush of log files (0 = write in log "
+ "files immediately for each line printed)"),
+ NULL, 0, 3600, "120", NULL, 0, NULL, NULL,
+ &logger_config_flush_delay_change, NULL, NULL, NULL);
logger_config_file_name_lower_case = weechat_config_new_option (
logger_config_file, ptr_section,
"name_lower_case", "boolean",
@@ -442,6 +493,8 @@ logger_config_read ()
rc = weechat_config_read (logger_config_file);
logger_config_loading = 0;
+ logger_config_flush_delay_change (NULL, NULL);
+
return rc;
}
diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c
index 612dedad1..c39fc7073 100644
--- a/src/plugins/logger/logger.c
+++ b/src/plugins/logger/logger.c
@@ -53,6 +53,7 @@ WEECHAT_PLUGIN_LICENSE(WEECHAT_LICENSE);
struct t_weechat_plugin *weechat_logger_plugin = NULL;
+struct t_hook *logger_timer = NULL; /* timer to flush log files */
char *logger_buf_write = NULL; /* buffer for writing a line */
@@ -588,6 +589,7 @@ logger_write_line (struct t_logger_buffer *logger_buffer,
"%s\n", (message) ? message : logger_buf_write);
if (message)
free (message);
+ logger_buffer->flush_needed = 1;
}
logger_buffer->write_start_info_line = 0;
}
@@ -601,9 +603,15 @@ logger_write_line (struct t_logger_buffer *logger_buffer,
fprintf (logger_buffer->log_file,
"%s\n", (message) ? message : logger_buf_write);
- fflush (logger_buffer->log_file);
if (message)
free (message);
+ logger_buffer->flush_needed = 1;
+
+ if (!logger_timer)
+ {
+ fflush (logger_buffer->log_file);
+ logger_buffer->flush_needed = 0;
+ }
}
/*
@@ -1201,6 +1209,40 @@ logger_print_cb (void *data, struct t_gui_buffer *buffer, time_t date,
}
/*
+ * logger_timer_cb: callback for logger timer
+ */
+
+int
+logger_timer_cb (void *data, int remaining_calls)
+{
+ struct t_logger_buffer *ptr_logger_buffer;
+
+ /* make C compiler happy */
+ (void) data;
+ (void) remaining_calls;
+
+ for (ptr_logger_buffer = logger_buffers; ptr_logger_buffer;
+ ptr_logger_buffer = ptr_logger_buffer->next_buffer)
+ {
+ if (ptr_logger_buffer->log_file && ptr_logger_buffer->flush_needed)
+ {
+ if (weechat_logger_plugin->debug >= 2)
+ {
+ weechat_printf_tags (NULL,
+ "no_log",
+ "%s: flush file %s",
+ LOGGER_PLUGIN_NAME,
+ ptr_logger_buffer->log_filename);
+ }
+ fflush (ptr_logger_buffer->log_file);
+ ptr_logger_buffer->flush_needed = 0;
+ }
+ }
+
+ return WEECHAT_RC_OK;
+}
+
+/*
* weechat_plugin_init: initialize logger plugin
*/
@@ -1285,6 +1327,12 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
/* make C compiler happy */
(void) plugin;
+ if (logger_timer)
+ {
+ weechat_unhook (logger_timer);
+ logger_timer = NULL;
+ }
+
logger_config_write ();
logger_stop_all (1);
diff --git a/src/plugins/logger/logger.h b/src/plugins/logger/logger.h
index ba7cc561d..7a11e747b 100644
--- a/src/plugins/logger/logger.h
+++ b/src/plugins/logger/logger.h
@@ -28,8 +28,11 @@
extern struct t_weechat_plugin *weechat_logger_plugin;
+extern struct t_hook *logger_timer;
+
extern void logger_start_buffer_all (int write_info_line);
extern void logger_stop_all (int write_info_line);
extern void logger_adjust_log_filenames ();
+extern int logger_timer_cb (void *data, int remaining_calls);
#endif /* __WEECHAT_LOGGER_H */