diff options
Diffstat (limited to 'ui/curses/ui.c')
| -rw-r--r-- | ui/curses/ui.c | 48 |
1 files changed, 8 insertions, 40 deletions
diff --git a/ui/curses/ui.c b/ui/curses/ui.c index 0f87c2d..3564ef3 100644 --- a/ui/curses/ui.c +++ b/ui/curses/ui.c @@ -1,5 +1,6 @@ +#include "logger.c" + #define LOG_LINE_COUNT 1024 -#define LOG_LINE_SIZE 1024 #define PANE_WIDTH 27 #define PROC_FIELD_WIDTH 21 #define PROC_PAGE_LINES 12 @@ -68,8 +69,6 @@ uint64_t g_wcursor_pointed; uint64_t g_log_cnt; unsigned g_log_ptr; unsigned g_log_scroll; -bool g_log_warns[LOG_LINE_COUNT]; -time_t g_log_times[LOG_LINE_COUNT]; char g_logs[LOG_LINE_COUNT][LOG_LINE_SIZE]; uint64_t g_vlin; uint64_t g_vsiz; @@ -796,12 +795,12 @@ void ui_print_ipc(int l) { // Log page functions // ---------------------------------------------------------------------------- void ui_info_impl(const char *format, ...) { - g_log_warns[g_log_ptr] = false; - g_log_times[g_log_ptr] = time(NULL); + assert(format); + assert(false); va_list args; va_start(args, format); - vsnprintf(g_logs[g_log_ptr], LOG_LINE_SIZE, format, args); + log_msg_to_buff(g_logs[g_log_ptr], LOG_LINE_SIZE, LOG_INFO, format, args); va_end(args); g_log_cnt++; @@ -809,12 +808,11 @@ void ui_info_impl(const char *format, ...) { } void ui_warn_impl(const char *format, ...) { - g_log_warns[g_log_ptr] = true; - g_log_times[g_log_ptr] = time(NULL); + assert(format); va_list args; va_start(args, format); - vsnprintf(g_logs[g_log_ptr], LOG_LINE_SIZE, format, args); + log_msg_to_buff(g_logs[g_log_ptr], LOG_LINE_SIZE, LOG_WARN, format, args); va_end(args); g_log_cnt++; @@ -833,37 +831,7 @@ void ui_print_log_line(unsigned lptr, int line) { ui_clear_log_line(line); if (strlen(g_logs[lptr])) { - struct tm tm = *localtime(&g_log_times[lptr]); - - ui_field( - line, - PANE_WIDTH, - PAIR_NORMAL, - A_NORMAL, - " %d-%02d-%02d %02d:%02d:%02d --", - tm.tm_year + 1900, - tm.tm_mon + 1, - tm.tm_mday, - tm.tm_hour, - tm.tm_min, - tm.tm_sec - ); - - ui_field( - line, - PANE_WIDTH + 25, - g_log_warns[lptr] ? PAIR_WARN : PAIR_HEADER, - A_NORMAL, - g_log_warns[lptr] ? "WARN" : "INFO" - ); - - ui_field( - line, - PANE_WIDTH + 30, - PAIR_NORMAL, - A_NORMAL, - g_logs[lptr] - ); + ui_field(line, PANE_WIDTH + 2, PAIR_NORMAL, A_NORMAL, g_logs[lptr]); } } |
