mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 21:36:37 +02:00
logger: add colors for backlog lines and end of backlog (task #11966)
This commit is contained in:
@@ -39,6 +39,11 @@ int logger_config_loading = 0;
|
||||
|
||||
struct t_config_option *logger_config_look_backlog;
|
||||
|
||||
/* logger config, color section */
|
||||
|
||||
struct t_config_option *logger_config_color_backlog_line;
|
||||
struct t_config_option *logger_config_color_backlog_end;
|
||||
|
||||
/* logger config, file section */
|
||||
|
||||
struct t_config_option *logger_config_file_auto_log;
|
||||
@@ -378,6 +383,29 @@ logger_config_init ()
|
||||
"new buffer (0 = no backlog)"),
|
||||
NULL, 0, INT_MAX, "20", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
/* color */
|
||||
ptr_section = weechat_config_new_section (logger_config_file, "color",
|
||||
0, 0,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL);
|
||||
if (!ptr_section)
|
||||
{
|
||||
weechat_config_free (logger_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
logger_config_color_backlog_line = weechat_config_new_option (
|
||||
logger_config_file, ptr_section,
|
||||
"backlog_line", "color",
|
||||
N_("color for backlog lines"),
|
||||
NULL, -1, 0, "darkgray", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
logger_config_color_backlog_end = weechat_config_new_option (
|
||||
logger_config_file, ptr_section,
|
||||
"backlog_end", "color",
|
||||
N_("color for line ending the backlog"),
|
||||
NULL, -1, 0, "darkgray", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
/* file */
|
||||
ptr_section = weechat_config_new_section (logger_config_file, "file",
|
||||
0, 0,
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
|
||||
extern struct t_config_option *logger_config_look_backlog;
|
||||
|
||||
extern struct t_config_option *logger_config_color_backlog_line;
|
||||
extern struct t_config_option *logger_config_color_backlog_end;
|
||||
|
||||
extern struct t_config_option *logger_config_file_auto_log;
|
||||
extern struct t_config_option *logger_config_file_name_lower_case;
|
||||
extern struct t_config_option *logger_config_file_path;
|
||||
|
||||
+19
-21
@@ -915,7 +915,7 @@ void
|
||||
logger_backlog (struct t_gui_buffer *buffer, const char *filename, int lines)
|
||||
{
|
||||
struct t_logger_line *last_lines, *ptr_lines;
|
||||
char *pos_message, *error;
|
||||
char *pos_message, *pos_tab, *error;
|
||||
time_t datetime, time_now;
|
||||
struct tm tm_line;
|
||||
int num_lines;
|
||||
@@ -947,25 +947,21 @@ logger_backlog (struct t_gui_buffer *buffer, const char *filename, int lines)
|
||||
datetime = mktime (&tm_line);
|
||||
pos_message[0] = '\t';
|
||||
}
|
||||
if (pos_message)
|
||||
{
|
||||
if (datetime != 0)
|
||||
{
|
||||
weechat_printf_date_tags (buffer, datetime,
|
||||
"no_highlight,notify_none",
|
||||
"%s", pos_message + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf_tags (buffer, "no_highlight,notify_none",
|
||||
"%s", ptr_lines->data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf_tags (buffer, "no_highlight,notify_none",
|
||||
"%s", ptr_lines->data);
|
||||
}
|
||||
pos_message = (pos_message && (datetime != 0)) ?
|
||||
pos_message + 1 : ptr_lines->data;
|
||||
pos_tab = strchr (pos_message, '\t');
|
||||
if (pos_tab)
|
||||
pos_tab[0] = '\0';
|
||||
weechat_printf_date_tags (buffer, datetime,
|
||||
"no_highlight,notify_none",
|
||||
"%s%s%s%s%s",
|
||||
weechat_color (weechat_config_string (logger_config_color_backlog_line)),
|
||||
pos_message,
|
||||
(pos_tab) ? "\t" : "",
|
||||
(pos_tab) ? weechat_color (weechat_config_string (logger_config_color_backlog_line)) : "",
|
||||
(pos_tab) ? pos_tab + 1 : "");
|
||||
if (pos_tab)
|
||||
pos_tab[0] = '\t';
|
||||
num_lines++;
|
||||
ptr_lines = ptr_lines->next_line;
|
||||
}
|
||||
@@ -974,7 +970,9 @@ logger_backlog (struct t_gui_buffer *buffer, const char *filename, int lines)
|
||||
if (num_lines > 0)
|
||||
{
|
||||
weechat_printf_tags (buffer, "no_highlight,notify_none",
|
||||
_("===\t========== End of backlog (%d lines) =========="),
|
||||
_("%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", "");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user