summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2010-01-26 16:36:55 +0100
committerSebastien Helleu <flashcode@flashtux.org>2010-01-26 16:36:55 +0100
commit99bfdfd2ff8701126c0254c838d35c20be1af652 (patch)
tree671b0c25c275728f007d19d268388beb17e6668d /src
parentaa41942ac19a6dd6f7f337c7b547626fb8d0d614 (diff)
downloadweechat-99bfdfd2ff8701126c0254c838d35c20be1af652.zip
Add signal "day_changed", allow date format in logger options path and mask (task #9430)
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-config.c6
-rw-r--r--src/plugins/logger/logger-buffer.c22
-rw-r--r--src/plugins/logger/logger-buffer.h2
-rw-r--r--src/plugins/logger/logger-config.c36
-rw-r--r--src/plugins/logger/logger.c356
-rw-r--r--src/plugins/logger/logger.h5
6 files changed, 310 insertions, 117 deletions
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index f63fac17c..384e42e69 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -344,7 +344,7 @@ config_day_change_timer_cb (void *data, int remaining_calls)
{
struct timeval tv_time;
struct tm *local_time;
- char text_time[1024], *text_time2;
+ char text_time[256], *text_time2;
struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
@@ -374,6 +374,10 @@ config_day_change_timer_cb (void *data, int remaining_calls)
if (text_time2)
free (text_time2);
gui_add_hotlist = 1;
+
+ /* send signal "day_changed" */
+ strftime (text_time, sizeof (text_time), "%Y-%m-%d", local_time);
+ hook_signal_send ("day_changed", WEECHAT_HOOK_SIGNAL_STRING, text_time);
}
config_day_change_old_day = local_time->tm_mday;
diff --git a/src/plugins/logger/logger-buffer.c b/src/plugins/logger/logger-buffer.c
index 665c7e5af..038d8e765 100644
--- a/src/plugins/logger/logger-buffer.c
+++ b/src/plugins/logger/logger-buffer.c
@@ -89,6 +89,7 @@ logger_buffer_add (struct t_gui_buffer *buffer, int log_level)
new_logger_buffer->log_file = NULL;
new_logger_buffer->log_enabled = 1;
new_logger_buffer->log_level = log_level;
+ new_logger_buffer->write_start_info_line = 1;
new_logger_buffer->prev_buffer = last_logger_buffer;
new_logger_buffer->next_buffer = NULL;
@@ -156,14 +157,9 @@ void
logger_buffer_free (struct t_logger_buffer *logger_buffer)
{
struct t_logger_buffer *new_logger_buffers;
+ struct t_gui_buffer *ptr_buffer;
- if (weechat_logger_plugin->debug)
- {
- weechat_printf (NULL,
- "%s: stop logging for buffer \"%s\"",
- LOGGER_PLUGIN_NAME,
- weechat_buffer_get_string (logger_buffer->buffer, "name"));
- }
+ ptr_buffer = logger_buffer->buffer;
/* remove logger buffer */
if (last_logger_buffer == logger_buffer)
@@ -182,10 +178,20 @@ logger_buffer_free (struct t_logger_buffer *logger_buffer)
/* free data */
if (logger_buffer->log_filename)
free (logger_buffer->log_filename);
+ if (logger_buffer->log_file)
+ fclose (logger_buffer->log_file);
free (logger_buffer);
logger_buffers = new_logger_buffers;
+
+ if (weechat_logger_plugin->debug)
+ {
+ weechat_printf (NULL,
+ "%s: stop logging for buffer \"%s\"",
+ LOGGER_PLUGIN_NAME,
+ weechat_buffer_get_string (ptr_buffer, "name"));
+ }
}
/*
@@ -216,6 +222,8 @@ logger_buffer_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!weechat_infolist_new_var_integer (ptr_item, "log_level", logger_buffer->log_level))
return 0;
+ if (!weechat_infolist_new_var_integer (ptr_item, "write_start_info_line", logger_buffer->write_start_info_line))
+ return 0;
return 1;
}
diff --git a/src/plugins/logger/logger-buffer.h b/src/plugins/logger/logger-buffer.h
index 519ae978f..a64f7fde4 100644
--- a/src/plugins/logger/logger-buffer.h
+++ b/src/plugins/logger/logger-buffer.h
@@ -29,6 +29,8 @@ struct t_logger_buffer
FILE *log_file; /* log file */
int log_enabled; /* log enabled ? */
int log_level; /* log level (0..9) */
+ int write_start_info_line; /* 1 if start info line must be */
+ /* written in file */
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 3a5deacce..dc61e5239 100644
--- a/src/plugins/logger/logger-config.c
+++ b/src/plugins/logger/logger-config.c
@@ -63,10 +63,7 @@ logger_config_change_file_option_restart_log (void *data,
(void) option;
if (!logger_config_loading)
- {
- logger_stop_all ();
- logger_start_buffer_all ();
- }
+ logger_adjust_log_filenames ();
}
/*
@@ -80,9 +77,9 @@ logger_config_level_change (void *data,
/* make C compiler happy */
(void) data;
(void) option;
-
+
if (!logger_config_loading)
- logger_start_buffer_all ();
+ logger_start_buffer_all (1);
}
/*
@@ -102,7 +99,7 @@ logger_config_level_delete_option (void *data,
weechat_config_option_free (option);
- logger_start_buffer_all ();
+ logger_start_buffer_all (1);
return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
}
@@ -161,7 +158,7 @@ logger_config_level_create_option (void *data,
}
if (!logger_config_loading)
- logger_start_buffer_all ();
+ logger_start_buffer_all (1);
return rc;
}
@@ -205,10 +202,7 @@ logger_config_mask_change (void *data,
(void) option;
if (!logger_config_loading)
- {
- logger_stop_all ();
- logger_start_buffer_all ();
- }
+ logger_adjust_log_filenames ();
}
/*
@@ -228,8 +222,7 @@ logger_config_mask_delete_option (void *data,
weechat_config_option_free (option);
- logger_stop_all ();
- logger_start_buffer_all ();
+ logger_adjust_log_filenames ();
return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
}
@@ -286,12 +279,9 @@ logger_config_mask_create_option (void *data,
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
}
-
+
if (!logger_config_loading)
- {
- logger_stop_all ();
- logger_start_buffer_all ();
- }
+ logger_adjust_log_filenames ();
return rc;
}
@@ -369,8 +359,9 @@ logger_config_init ()
logger_config_file_path = weechat_config_new_option (
logger_config_file, ptr_section,
"path", "string",
- N_("path for WeeChat log files (\"%h\" will be replaced by WeeChat "
- "home, \"~/.weechat\" by default)"),
+ N_("path for WeeChat log files; \"%h\" at beginning of string is "
+ "replaced by WeeChat home (\"~/.weechat\" by default); date "
+ "specifiers are permitted (see man strftime)"),
NULL, 0, 0, "%h/logs/", NULL, 0, NULL, NULL,
&logger_config_change_file_option_restart_log, NULL, NULL, NULL);
logger_config_file_mask = weechat_config_new_option (
@@ -379,7 +370,8 @@ logger_config_init ()
N_("default file name mask for log files (format is "
"\"directory/to/file\" or \"file\", without first \"/\" because "
"\"path\" option is used to build complete path to file); local "
- "buffer variables are permitted"),
+ "buffer variables are permitted; date specifiers are permitted "
+ "(see man strftime)"),
NULL, 0, 0, "$plugin.$name.weechatlog", NULL, 0, NULL, NULL,
&logger_config_change_file_option_restart_log, NULL, NULL, NULL);
logger_config_file_replacement_char = weechat_config_new_option (
diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c
index 243be1515..246f37b4d 100644
--- a/src/plugins/logger/logger.c
+++ b/src/plugins/logger/logger.c
@@ -55,6 +55,76 @@ char *logger_buf_write = NULL; /* buffer for writing a line */
/*
+ * logger_get_file_path: get logger file path option, special vars are replaced:
+ * - "%h" (at beginning of string): WeeChat home
+ * - "~": user home
+ * - date/time specifiers (see man strftime)
+ * note: returned value has to be free() after use
+ */
+
+char *
+logger_get_file_path ()
+{
+ char *file_path, *file_path2, *file_path3;
+ const char *weechat_dir;
+ int length;
+ time_t seconds;
+ struct tm *date_tmp;
+
+ file_path = NULL;
+ file_path2 = NULL;
+ file_path3 = NULL;
+
+ weechat_dir = weechat_info_get ("weechat_dir", "");
+ if (!weechat_dir)
+ goto end;
+
+ /* replace "~" with user home */
+ file_path = weechat_string_replace (weechat_config_string (logger_config_file_path),
+ "~", getenv ("HOME"));
+ if (!file_path)
+ goto end;
+
+ /* replace "%h" with WeeChat home (at beginning of string only) */
+ if (strncmp (file_path, "%h", 2) == 0)
+ {
+ length = strlen (weechat_dir) + strlen (file_path + 2) + 1;
+ file_path2 = malloc (length);
+ if (file_path2)
+ snprintf (file_path2, length, "%s%s", weechat_dir, file_path + 2);
+ }
+ else
+ file_path2 = strdup (file_path);
+ if (!file_path2)
+ goto end;
+
+ /* replace date/time specifiers in path */
+ length = strlen (file_path2) + 256 + 1;
+ file_path3 = malloc (length);
+ if (!file_path3)
+ goto end;
+ seconds = time (NULL);
+ date_tmp = localtime (&seconds);
+ file_path3[0] = '\0';
+ strftime (file_path3, length - 1, file_path2, date_tmp);
+
+ if (weechat_logger_plugin->debug)
+ {
+ weechat_printf (NULL,
+ "%s: file path = \"%s\"",
+ LOGGER_PLUGIN_NAME, file_path3);
+ }
+
+end:
+ if (file_path)
+ free (file_path);
+ if (file_path2)
+ free (file_path2);
+
+ return file_path3;
+}
+
+/*
* logger_create_directory: create logger directory
* return 1 if success (directory created or already
* exists), 0 if failed
@@ -64,32 +134,16 @@ int
logger_create_directory ()
{
int rc;
- char *dir1, *dir2;
- const char *weechat_dir;
+ char *file_path;
rc = 1;
-
- dir1 = weechat_string_replace (weechat_config_string (logger_config_file_path),
- "~", getenv ("HOME"));
- if (dir1)
+
+ file_path = logger_get_file_path ();
+ if (file_path)
{
- weechat_dir = weechat_info_get ("weechat_dir", "");
- if (weechat_dir)
- {
- dir2 = weechat_string_replace (dir1, "%h", weechat_dir);
- if (dir2)
- {
- if (!weechat_mkdir_parents (dir2, 0700))
- rc = 0;
-
- free (dir2);
- }
- else
- rc = 0;
- }
- else
+ if (!weechat_mkdir_parents (file_path, 0700))
rc = 0;
- free (dir1);
+ free (file_path);
}
else
rc = 0;
@@ -238,41 +292,35 @@ logger_get_mask_for_buffer (struct t_gui_buffer *buffer)
}
/*
- * logger_get_filename: build log filename for a buffer
+ * logger_get_mask_expanded: get expanded mask for a buffer, special vars are
+ * replaced:
+ * - local variables of buffer ($plugin, $name, ..)
+ * - date/time specifiers (see man strftime)
+ * note: returned value has to be free() after use
*/
char *
-logger_get_filename (struct t_gui_buffer *buffer)
+logger_get_mask_expanded (struct t_gui_buffer *buffer, const char *mask)
{
- char *res, *mask2, *mask_decoded, *mask_decoded2, *mask_decoded3;
- const char *mask;
- const char *dir_separator, *weechat_dir;
- char *log_path, *log_path2, *pos_last_sep;
+ char *mask2, *mask_decoded, *mask_decoded2, *mask_decoded3, *mask_decoded4;
+ const char *dir_separator;
int length;
+ time_t seconds;
+ struct tm *date_tmp;
- res = NULL;
mask2 = NULL;
mask_decoded = NULL;
mask_decoded2 = NULL;
mask_decoded3 = NULL;
- log_path = NULL;
- log_path2 = NULL;
-
+ mask_decoded4 = NULL;
+
dir_separator = weechat_info_get ("dir_separator", "");
- weechat_dir = weechat_info_get ("weechat_dir", "");
-
- /* get filename mask for buffer */
- mask = logger_get_mask_for_buffer (buffer);
- if (!mask)
- {
- weechat_printf (NULL,
- _("%s%s: unable to find filename mask for buffer "
- "\"%s\", logging is disabled for this buffer"),
- weechat_prefix ("error"), LOGGER_PLUGIN_NAME,
- weechat_buffer_get_string (buffer, "name"));
+ if (!dir_separator)
return NULL;
- }
+ /* we first replace directory separator (commonly '/') by \01 because
+ buffer mask can contain this char, and will be replaced by replacement
+ char ('_' by default) */
mask2 = weechat_string_replace (mask, dir_separator, "\01");
if (!mask2)
goto end;
@@ -287,11 +335,26 @@ logger_get_filename (struct t_gui_buffer *buffer)
if (!mask_decoded2)
goto end;
+ /* restore directory separator */
mask_decoded3 = weechat_string_replace (mask_decoded2,
"\01", dir_separator);
if (!mask_decoded3)
goto end;
+ /* replace date/time specifiers in mask */
+ length = strlen (mask_decoded3) + 256 + 1;
+ mask_decoded4 = malloc (length);
+ if (!mask_decoded4)
+ goto end;
+ seconds = time (NULL);
+ date_tmp = localtime (&seconds);
+ mask_decoded4[0] = '\0';
+ strftime (mask_decoded4, length - 1, mask_decoded3, date_tmp);
+
+ /* convert to lower case? */
+ if (weechat_config_boolean (logger_config_file_name_lower_case))
+ weechat_string_tolower (mask_decoded4);
+
if (weechat_logger_plugin->debug)
{
weechat_printf (NULL,
@@ -299,37 +362,10 @@ logger_get_filename (struct t_gui_buffer *buffer)
"decoded mask = \"%s\"",
LOGGER_PLUGIN_NAME,
weechat_buffer_get_string (buffer, "name"),
- mask, mask_decoded3);
+ mask, mask_decoded4);
}
- if (weechat_config_boolean (logger_config_file_name_lower_case))
- weechat_string_tolower (mask_decoded3);
-
- log_path = weechat_string_replace (weechat_config_string (logger_config_file_path),
- "~", getenv ("HOME"));
- log_path2 = weechat_string_replace (log_path, "%h", weechat_dir);
-
- if (dir_separator && weechat_dir && log_path && log_path2)
- {
- length = strlen (log_path2) + strlen (mask_decoded3) + 1;
- res = malloc (length);
- if (res)
- {
- snprintf (res, length, "%s%s", log_path2, mask_decoded3);
- pos_last_sep = strrchr (res, dir_separator[0]);
- if (pos_last_sep)
- pos_last_sep[0] = '\0';
- weechat_mkdir_parents (res, 0700);
- if (pos_last_sep)
- pos_last_sep[0] = dir_separator[0];
- }
- }
-
end:
- if (log_path)
- free (log_path);
- if (log_path2)
- free (log_path2);
if (mask2)
free (mask2);
if (mask_decoded)
@@ -339,6 +375,70 @@ end:
if (mask_decoded3)
free (mask_decoded3);
+ return mask_decoded4;
+}
+
+/*
+ * logger_get_filename: build log filename for a buffer
+ */
+
+char *
+logger_get_filename (struct t_gui_buffer *buffer)
+{
+ char *res, *mask_expanded, *file_path;
+ const char *mask;
+ const char *dir_separator, *weechat_dir;
+ int length;
+
+ res = NULL;
+ mask_expanded = NULL;
+ file_path = NULL;
+
+ dir_separator = weechat_info_get ("dir_separator", "");
+ if (!dir_separator)
+ return NULL;
+ weechat_dir = weechat_info_get ("weechat_dir", "");
+ if (!weechat_dir)
+ return NULL;
+
+ /* get filename mask for buffer */
+ mask = logger_get_mask_for_buffer (buffer);
+ if (!mask)
+ {
+ weechat_printf (NULL,
+ _("%s%s: unable to find filename mask for buffer "
+ "\"%s\", logging is disabled for this buffer"),
+ weechat_prefix ("error"), LOGGER_PLUGIN_NAME,
+ weechat_buffer_get_string (buffer, "name"));
+ return NULL;
+ }
+
+ mask_expanded = logger_get_mask_expanded (buffer, mask);
+ if (!mask_expanded)
+ goto end;
+
+ file_path = logger_get_file_path ();
+ if (!file_path)
+ goto end;
+
+ /* build string with path + mask */
+ length = strlen (file_path) + strlen (dir_separator) +
+ strlen (mask_expanded) + 1;
+ res = malloc (length);
+ if (res)
+ {
+ snprintf (res, length, "%s%s%s",
+ file_path,
+ (file_path[strlen (file_path) - 1] == dir_separator[0]) ? "" : dir_separator,
+ mask_expanded);
+ }
+
+end:
+ if (mask_expanded)
+ free (mask_expanded);
+ if (file_path)
+ free (file_path);
+
return res;
}
@@ -349,9 +449,11 @@ end:
void
logger_set_log_filename (struct t_logger_buffer *logger_buffer)
{
- char *log_filename;
+ char *log_filename, *pos_last_sep;
+ const char *dir_separator;
struct t_logger_buffer *ptr_logger_buffer;
+ /* get log filename for buffer */
log_filename = logger_get_filename (logger_buffer->buffer);
if (!log_filename)
{
@@ -362,6 +464,7 @@ logger_set_log_filename (struct t_logger_buffer *logger_buffer)
return;
}
+ /* log file is already used by another buffer? */
ptr_logger_buffer = logger_buffer_search_log_filename (log_filename);
if (ptr_logger_buffer)
{
@@ -377,6 +480,20 @@ logger_set_log_filename (struct t_logger_buffer *logger_buffer)
return;
}
+ /* create directory for path in "log_filename" */
+ dir_separator = weechat_info_get ("dir_separator", "");
+ if (dir_separator)
+ {
+ pos_last_sep = strrchr (log_filename, dir_separator[0]);
+ if (pos_last_sep)
+ {
+ pos_last_sep[0] = '\0';
+ weechat_mkdir_parents (log_filename, 0700);
+ pos_last_sep[0] = dir_separator[0];
+ }
+ }
+
+ /* set log filename */
logger_buffer->log_filename = log_filename;
}
@@ -422,7 +539,6 @@ logger_write_line (struct t_logger_buffer *logger_buffer,
}
if (!logger_buffer->log_filename)
logger_set_log_filename (logger_buffer);
-
if (!logger_buffer->log_filename)
{
logger_buffer_free (logger_buffer);
@@ -441,15 +557,18 @@ logger_write_line (struct t_logger_buffer *logger_buffer,
return;
}
- if (weechat_config_boolean (logger_config_file_info_lines))
+ if (weechat_config_boolean (logger_config_file_info_lines)
+ && logger_buffer->write_start_info_line)
{
seconds = time (NULL);
date_tmp = localtime (&seconds);
buf_time[0] = '\0';
if (date_tmp)
+ {
strftime (buf_time, sizeof (buf_time) - 1,
weechat_config_string (logger_config_file_time_format),
date_tmp);
+ }
snprintf (logger_buf_write, LOGGER_BUF_WRITE_SIZE,
_("%s\t**** Beginning of log ****"),
buf_time);
@@ -460,6 +579,7 @@ logger_write_line (struct t_logger_buffer *logger_buffer,
if (message)
free (message);
}
+ logger_buffer->write_start_info_line = 0;
}
va_start (argptr, format);
@@ -498,9 +618,11 @@ logger_stop (struct t_logger_buffer *logger_buffer, int write_info_line)
date_tmp = localtime (&seconds);
buf_time[0] = '\0';
if (date_tmp)
+ {
strftime (buf_time, sizeof (buf_time) - 1,
weechat_config_string (logger_config_file_time_format),
date_tmp);
+ }
logger_write_line (logger_buffer,
_("%s\t**** End of log ****"),
buf_time);
@@ -516,11 +638,11 @@ logger_stop (struct t_logger_buffer *logger_buffer, int write_info_line)
*/
void
-logger_stop_all ()
+logger_stop_all (int write_info_line)
{
while (logger_buffers)
{
- logger_stop (logger_buffers, 1);
+ logger_stop (logger_buffers, write_info_line);
}
}
@@ -529,7 +651,7 @@ logger_stop_all ()
*/
void
-logger_start_buffer (struct t_gui_buffer *buffer)
+logger_start_buffer (struct t_gui_buffer *buffer, int write_info_line)
{
struct t_logger_buffer *ptr_logger_buffer;
int log_level, log_enabled;
@@ -571,6 +693,8 @@ logger_start_buffer (struct t_gui_buffer *buffer)
}
}
}
+ if (ptr_logger_buffer)
+ ptr_logger_buffer->write_start_info_line = write_info_line;
}
}
@@ -579,7 +703,7 @@ logger_start_buffer (struct t_gui_buffer *buffer)
*/
void
-logger_start_buffer_all ()
+logger_start_buffer_all (int write_info_line)
{
struct t_infolist *ptr_infolist;
@@ -589,7 +713,8 @@ logger_start_buffer_all ()
while (weechat_infolist_next (ptr_infolist))
{
logger_start_buffer (weechat_infolist_pointer (ptr_infolist,
- "pointer"));
+ "pointer"),
+ write_info_line);
}
weechat_infolist_free (ptr_infolist);
}
@@ -730,7 +855,7 @@ logger_buffer_opened_signal_cb (void *data, const char *signal,
(void) signal;
(void) type_data;
- logger_start_buffer (signal_data);
+ logger_start_buffer (signal_data, 1);
return WEECHAT_RC_OK;
}
@@ -767,7 +892,7 @@ logger_buffer_renamed_signal_cb (void *data, const char *signal,
(void) type_data;
logger_stop (logger_buffer_search_buffer (signal_data), 1);
- logger_start_buffer (signal_data);
+ logger_start_buffer (signal_data, 1);
return WEECHAT_RC_OK;
}
@@ -888,7 +1013,7 @@ logger_start_signal_cb (void *data, const char *signal, const char *type_data,
(void) signal;
(void) type_data;
- logger_start_buffer (signal_data);
+ logger_start_buffer (signal_data, 1);
return WEECHAT_RC_OK;
}
@@ -916,6 +1041,66 @@ logger_stop_signal_cb (void *data, const char *signal, const char *type_data,
}
/*
+ * logger_adjust_log_filenames: adjust log filenames for all buffers
+ * filename can change if config option is changed,
+ * or if day of system date has changed
+ */
+
+void
+logger_adjust_log_filenames ()
+{
+ struct t_infolist *ptr_infolist;
+ struct t_logger_buffer *ptr_logger_buffer;
+ struct t_gui_buffer *ptr_buffer;
+ char *log_filename;
+
+ ptr_infolist = weechat_infolist_get ("buffer", NULL, NULL);
+ if (ptr_infolist)
+ {
+ while (weechat_infolist_next (ptr_infolist))
+ {
+ ptr_buffer = weechat_infolist_pointer (ptr_infolist, "pointer");
+ ptr_logger_buffer = logger_buffer_search_buffer (ptr_buffer);
+ if (ptr_logger_buffer && ptr_logger_buffer->log_filename)
+ {
+ log_filename = logger_get_filename (ptr_logger_buffer->buffer);
+ if (log_filename)
+ {
+ if (strcmp (log_filename, ptr_logger_buffer->log_filename) != 0)
+ {
+ /* log filename has changed (probably due to day change),
+ then we'll use new filename */
+ logger_stop (ptr_logger_buffer, 1);
+ logger_start_buffer (ptr_buffer, 1);
+ }
+ free (log_filename);
+ }
+ }
+ }
+ weechat_infolist_free (ptr_infolist);
+ }
+}
+
+/*
+ * logger_day_changed_signal_cb: callback for "day_changed" signal
+ */
+
+int
+logger_day_changed_signal_cb (void *data, const char *signal,
+ const char *type_data, void *signal_data)
+{
+ /* make C compiler happy */
+ (void) data;
+ (void) signal;
+ (void) type_data;
+ (void) signal_data;
+
+ logger_adjust_log_filenames ();
+
+ return WEECHAT_RC_OK;
+}
+
+/*
* logger_line_log_level: get log level for a line (with its tags)
*/
@@ -1040,7 +1225,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
" || disable",
&logger_command_cb, NULL);
- logger_start_buffer_all ();
+ logger_start_buffer_all (1);
weechat_hook_signal ("buffer_opened", &logger_buffer_opened_signal_cb, NULL);
weechat_hook_signal ("buffer_closing", &logger_buffer_closing_signal_cb, NULL);
@@ -1048,6 +1233,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
weechat_hook_signal ("logger_backlog", &logger_backlog_signal_cb, NULL);
weechat_hook_signal ("logger_start", &logger_start_signal_cb, NULL);
weechat_hook_signal ("logger_stop", &logger_stop_signal_cb, NULL);
+ weechat_hook_signal ("day_changed", &logger_day_changed_signal_cb, NULL);
weechat_hook_print (NULL, NULL, NULL, 1, &logger_print_cb, NULL);
@@ -1068,7 +1254,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
logger_config_write ();
- logger_stop_all ();
+ logger_stop_all (1);
logger_config_free ();
diff --git a/src/plugins/logger/logger.h b/src/plugins/logger/logger.h
index 43ccc6ff2..1ce937bca 100644
--- a/src/plugins/logger/logger.h
+++ b/src/plugins/logger/logger.h
@@ -28,7 +28,8 @@
extern struct t_weechat_plugin *weechat_logger_plugin;
-extern void logger_start_buffer_all ();
-extern void logger_stop_all ();
+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 ();
#endif /* logger.h */