summaryrefslogtreecommitdiff
path: root/src/plugins/logger/logger.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2013-08-25 09:39:59 +0200
committerSebastien Helleu <flashcode@flashtux.org>2013-08-25 09:39:59 +0200
commit03b6b4c1cf77f1fccb92295c4528406245382c69 (patch)
treede390f78d7132a9b6aef4c5eaca39ca259486124 /src/plugins/logger/logger.c
parent73f2c2c48833568f0eb21b73ca8fed5603643d93 (diff)
downloadweechat-03b6b4c1cf77f1fccb92295c4528406245382c69.zip
core: display day change message dynamically (do not store it as a line in buffer) (task #12775)
Changes in options: - rename option weechat.look.day_change_time_format to weechat.look.day_change_message (color codes are allowed in this option) - new option weechat.color.chat_day_change.
Diffstat (limited to 'src/plugins/logger/logger.c')
-rw-r--r--src/plugins/logger/logger.c43
1 files changed, 8 insertions, 35 deletions
diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c
index 183905b6a..8be65132a 100644
--- a/src/plugins/logger/logger.c
+++ b/src/plugins/logger/logger.c
@@ -928,23 +928,15 @@ logger_backlog (struct t_gui_buffer *buffer, const char *filename, int lines)
{
const char *charset;
struct t_logger_line *last_lines, *ptr_lines;
- char *pos_message, *pos_tab, *error, *message, text_time[256], *text_time2;
- struct timeval tv_time;
- struct tm *local_time;
+ char *pos_message, *pos_tab, *error, *message;
time_t datetime, time_now;
struct tm tm_line;
- int num_lines, old_mday, old_mon, old_year;
+ int num_lines;
charset = weechat_info_get ("charset_terminal", "");
weechat_buffer_set (buffer, "print_hooks_enabled", "0");
- gettimeofday (&tv_time, NULL);
- local_time = localtime (&tv_time.tv_sec);
- old_mday = local_time->tm_mday;
- old_mon = local_time->tm_mon;
- old_year = local_time->tm_year;
-
num_lines = 0;
last_lines = logger_tail_file (filename, lines);
ptr_lines = last_lines;
@@ -968,27 +960,7 @@ logger_backlog (struct t_gui_buffer *buffer, const char *filename, int lines)
weechat_config_string (logger_config_file_time_format),
&tm_line);
if (error && !error[0] && (tm_line.tm_year > 0))
- {
datetime = mktime (&tm_line);
- if ((tm_line.tm_mday != old_mday)
- || (tm_line.tm_mon != old_mon)
- || (tm_line.tm_year != old_year))
- {
- strftime (text_time, sizeof (text_time),
- weechat_config_string (weechat_config_get ("weechat.look.day_change_time_format")),
- &tm_line);
- text_time2 = weechat_iconv_to_internal (NULL, text_time);
- weechat_printf_tags (buffer,
- "no_highlight,notify_none,logger_backlog_date",
- _("\t\tDay changed to %s"),
- (text_time2) ? text_time2 : text_time);
- if (text_time2)
- free (text_time2);
- old_mday = tm_line.tm_mday;
- old_mon = tm_line.tm_mon;
- old_year = tm_line.tm_year;
- }
- }
pos_message[0] = '\t';
}
pos_message = (pos_message && (datetime != 0)) ?
@@ -1019,11 +991,12 @@ logger_backlog (struct t_gui_buffer *buffer, const char *filename, int lines)
logger_tail_free (last_lines);
if (num_lines > 0)
{
- weechat_printf_tags (buffer, "no_highlight,notify_none,logger_backlog_end",
- _("%s===\t%s========== End of backlog (%d lines) =========="),
- weechat_color (weechat_config_string (logger_config_color_backlog_end)),
- weechat_color (weechat_config_string (logger_config_color_backlog_end)),
- num_lines);
+ weechat_printf_date_tags (buffer, datetime,
+ "no_highlight,notify_none,logger_backlog_end",
+ _("%s===\t%s========== End of backlog (%d lines) =========="),
+ weechat_color (weechat_config_string (logger_config_color_backlog_end)),
+ weechat_color (weechat_config_string (logger_config_color_backlog_end)),
+ num_lines);
weechat_buffer_set (buffer, "unread", "");
}
weechat_buffer_set (buffer, "print_hooks_enabled", "1");