aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/logger.c25
-rw-r--r--core/tui.c14
2 files changed, 31 insertions, 8 deletions
diff --git a/core/logger.c b/core/logger.c
index f665908..880c231 100644
--- a/core/logger.c
+++ b/core/logger.c
@@ -1,5 +1,6 @@
#include <assert.h>
#include <stdarg.h>
+#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <time.h>
@@ -25,20 +26,30 @@ void log_msg_to_buff(char *out, int size, enum LogLevel level, bool colored, con
long msec = ts.tv_nsec / 1000000;
struct tm tm = *localtime(&ts.tv_sec);
pid_t pid = getpid();
-
char *level_str = NULL;
+
switch (level) {
- case LOG_INFO: level_str = "INFO"; break;
- case LOG_WARN: level_str = "WARN"; break;
- default: assert(false);
+ case LOG_INFO:
+ level_str = "INFO";
+ break;
+ case LOG_WARN:
+ level_str = "WARN";
+ break;
+ default:
+ assert(false);
}
char *color_code = NULL;
if (colored) {
switch (level) {
- case LOG_INFO: color_code = "\033[1;32m"; break;
- case LOG_WARN: color_code = "\033[1;33m"; break;
- default: assert(false);
+ case LOG_INFO:
+ color_code = "\033[1;32m";
+ break;
+ case LOG_WARN:
+ color_code = "\033[1;33m";
+ break;
+ default:
+ assert(false);
}
}
diff --git a/core/tui.c b/core/tui.c
index 6c27ff5..4fc2ce4 100644
--- a/core/tui.c
+++ b/core/tui.c
@@ -1,3 +1,6 @@
+#define PANE_WIDTH 27
+#define PANE_AND_MARGIN_WIDTH (PANE_WIDTH + 2)
+
enum {
PAIR_NORMAL = 0,
};
@@ -70,17 +73,26 @@ void tui_field(int line, int col, int color, int attr, const char *format, ...)
void tui_str_field(int l, const char *label, const char *value) {
assert(label);
+ assert(strlen(label) <= 4);
assert(value);
- tui_line(false, l, PAIR_NORMAL, A_NORMAL, "%s : %18s", label, value);
+ tui_line(false, l, PAIR_NORMAL, A_NORMAL, "%-4s : %18s", label, value);
}
void tui_ulx_field(int l, const char *label, uint64_t value) {
assert(label);
+ assert(strlen(label) <= 4);
tui_line(false, l, PAIR_NORMAL, A_NORMAL, "%-4s : %#18lx", label, value);
}
+void tui_uld_field(int l, const char *label, uint64_t value) {
+ assert(label);
+ assert(strlen(label) <= 4);
+ tui_line(false, l, PAIR_NORMAL, A_NORMAL, "%-4s : %#18ld", label, value);
+}
+
void tui_float_field(int l, const char *label, float value) {
assert(label);
+ assert(strlen(label) <= 4);
tui_line(false, l, PAIR_NORMAL, A_NORMAL, "%-4s : %18.1f", label, value);
}