aboutsummaryrefslogtreecommitdiff
path: root/ui/daemon/ui.c
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2026-04-23 04:08:40 +0200
committerPaul Oliver <contact@pauloliver.dev>2026-04-23 04:08:40 +0200
commit397286c87dc9aa3cba458973bdc65b3f3be14657 (patch)
tree78d857c87182784fd9a86450973c7ebe7cac0e48 /ui/daemon/ui.c
parentf0876156404da87782c4b0cf2b8086e0859e63c1 (diff)
Unifies logging between C and Python
Diffstat (limited to 'ui/daemon/ui.c')
-rw-r--r--ui/daemon/ui.c52
1 files changed, 4 insertions, 48 deletions
diff --git a/ui/daemon/ui.c b/ui/daemon/ui.c
index 269d5d7..0e4ea15 100644
--- a/ui/daemon/ui.c
+++ b/ui/daemon/ui.c
@@ -1,52 +1,8 @@
+#include "logger.c"
+
volatile bool g_running;
uint64_t g_step_block;
-void info_impl(const char *restrict fmt, ...) {
- assert(fmt);
-
- time_t t = time(NULL);
- struct tm tm = *localtime(&t);
- printf(
- "\r%d-%02d-%02d %02d:%02d:%02d -- \033[1;34mINFO\033[0m ",
- tm.tm_year + 1900,
- tm.tm_mon + 1,
- tm.tm_mday,
- tm.tm_hour,
- tm.tm_min,
- tm.tm_sec
- );
-
- va_list args;
- va_start(args, fmt);
- vprintf(fmt, args);
- va_end(args);
-
- printf("\n");
-}
-
-void warn_impl(const char *restrict fmt, ...) {
- assert(fmt);
-
- time_t t = time(NULL);
- struct tm tm = *localtime(&t);
- printf(
- "\r%d-%02d-%02d %02d:%02d:%02d -- \033[1;33mWARN\033[0m ",
- tm.tm_year + 1900,
- tm.tm_mon + 1,
- tm.tm_mday,
- tm.tm_hour,
- tm.tm_min,
- tm.tm_sec
- );
-
- va_list args;
- va_start(args, fmt);
- vprintf(fmt, args);
- va_end(args);
-
- printf("\n");
-}
-
void sig_handler(int signo) {
(void)signo;
@@ -78,8 +34,8 @@ void step_block(void) {
int main(void) {
g_running = true;
g_step_block = 1;
- g_info = info_impl;
- g_warn = warn_impl;
+ g_info = log_info;
+ g_warn = log_warn;
signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler);