summaryrefslogtreecommitdiff
path: root/src/core/hook
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-12-26 18:37:21 +0100
committerSébastien Helleu <flashcode@flashtux.org>2023-12-26 19:44:37 +0100
commit9fb3d3f14c17f8307f04907d5f57034410dc7010 (patch)
tree239415921e803382adf1abb9a334456c5d96711b /src/core/hook
parent57f80a4c1fac3d5b3c194206c900b1066f9a565e (diff)
downloadweechat-9fb3d3f14c17f8307f04907d5f57034410dc7010.zip
core: store microseconds in buffer lines (closes #649)
Diffstat (limited to 'src/core/hook')
-rw-r--r--src/core/hook/wee-hook-line.c2
-rw-r--r--src/core/hook/wee-hook-print.c1
-rw-r--r--src/core/hook/wee-hook-print.h8
-rw-r--r--src/core/hook/wee-hook-timer.c44
4 files changed, 22 insertions, 33 deletions
diff --git a/src/core/hook/wee-hook-line.c b/src/core/hook/wee-hook-line.c
index 1d29be96a..d3414ea9f 100644
--- a/src/core/hook/wee-hook-line.c
+++ b/src/core/hook/wee-hook-line.c
@@ -168,7 +168,9 @@ hook_line_exec (struct t_gui_line *line)
gui_buffer_type_string[line->data->buffer->type]);
HASHTABLE_SET_INT("y", line->data->y);
HASHTABLE_SET_TIME("date", line->data->date);
+ HASHTABLE_SET_INT("date_usec", line->data->date_usec);
HASHTABLE_SET_TIME("date_printed", line->data->date_printed);
+ HASHTABLE_SET_INT("date_usec_printed", line->data->date_usec_printed);
HASHTABLE_SET_STR_NOT_NULL("str_time", line->data->str_time);
HASHTABLE_SET_INT("tags_count", line->data->tags_count);
str_tags = string_rebuild_split_string (
diff --git a/src/core/hook/wee-hook-print.c b/src/core/hook/wee-hook-print.c
index 6c95e3e11..bea7bf2ff 100644
--- a/src/core/hook/wee-hook-print.c
+++ b/src/core/hook/wee-hook-print.c
@@ -168,6 +168,7 @@ hook_print_exec (struct t_gui_buffer *buffer, struct t_gui_line *line)
ptr_hook->callback_data,
buffer,
line->data->date,
+ line->data->date_usec,
line->data->tags_count,
(const char **)line->data->tags_array,
(int)line->data->displayed, (int)line->data->highlight,
diff --git a/src/core/hook/wee-hook-print.h b/src/core/hook/wee-hook-print.h
index 8eeb1eb0f..d32334d17 100644
--- a/src/core/hook/wee-hook-print.h
+++ b/src/core/hook/wee-hook-print.h
@@ -31,10 +31,10 @@ struct t_gui_line;
typedef int (t_hook_callback_print)(const void *pointer, void *data,
struct t_gui_buffer *buffer,
- time_t date, int tags_count,
- const char **tags, int displayed,
- int highlight, const char *prefix,
- const char *message);
+ time_t date, int date_usec,
+ int tags_count, const char **tags,
+ int displayed, int highlight,
+ const char *prefix, const char *message);
struct t_hook_print
{
diff --git a/src/core/hook/wee-hook-timer.c b/src/core/hook/wee-hook-timer.c
index 418d22304..a68e115c6 100644
--- a/src/core/hook/wee-hook-timer.c
+++ b/src/core/hook/wee-hook-timer.c
@@ -415,9 +415,7 @@ hook_timer_add_to_infolist (struct t_infolist_item *item,
void
hook_timer_print_log (struct t_hook *hook)
{
- struct tm *local_time;
- time_t seconds;
- char text_time[1024];
+ char text_time[128];
if (!hook || !hook->hook_data)
return;
@@ -427,30 +425,18 @@ hook_timer_print_log (struct t_hook *hook)
log_printf (" interval. . . . . . . : %ld", HOOK_TIMER(hook, interval));
log_printf (" align_second. . . . . : %d", HOOK_TIMER(hook, align_second));
log_printf (" remaining_calls . . . : %d", HOOK_TIMER(hook, remaining_calls));
- text_time[0] = '\0';
- seconds = HOOK_TIMER(hook, last_exec).tv_sec;
- local_time = localtime (&seconds);
- if (local_time)
- {
- if (strftime (text_time, sizeof (text_time),
- "%d/%m/%Y %H:%M:%S", local_time) == 0)
- text_time[0] = '\0';
- }
- log_printf (" last_exec.tv_sec. . . : %lld (%s)",
- (long long)(HOOK_TIMER(hook, last_exec.tv_sec)),
- text_time);
- log_printf (" last_exec.tv_usec . . : %ld", HOOK_TIMER(hook, last_exec.tv_usec));
- text_time[0] = '\0';
- seconds = HOOK_TIMER(hook, next_exec).tv_sec;
- local_time = localtime (&seconds);
- if (local_time)
- {
- if (strftime (text_time, sizeof (text_time),
- "%d/%m/%Y %H:%M:%S", local_time) == 0)
- text_time[0] = '\0';
- }
- log_printf (" next_exec.tv_sec. . . : %lld (%s)",
- (long long)(HOOK_TIMER(hook, next_exec.tv_sec)),
- text_time);
- log_printf (" next_exec.tv_usec . . : %ld", HOOK_TIMER(hook, next_exec.tv_usec));
+ util_strftimeval (text_time, sizeof (text_time),
+ "%Y-%m-%dT%H:%M:%S.%f", &(HOOK_TIMER(hook, last_exec)));
+ log_printf (" last_exec . . . . . . : %s", text_time);
+ log_printf (" tv_sec. . . . . . . : %lld",
+ (long long)(HOOK_TIMER(hook, last_exec.tv_sec)));
+ log_printf (" tv_usec. . . . . . : %ld",
+ HOOK_TIMER(hook, last_exec.tv_usec));
+ util_strftimeval (text_time, sizeof (text_time),
+ "%Y-%m-%dT%H:%M:%S.%f", &(HOOK_TIMER(hook, next_exec)));
+ log_printf (" last_exec . . . . . . : %s", text_time);
+ log_printf (" tv_sec. . . . . . . : %lld",
+ (long long)(HOOK_TIMER(hook, next_exec.tv_sec)));
+ log_printf (" tv_usec. . . . . . : %ld",
+ HOOK_TIMER(hook, next_exec.tv_usec));
}