From 8739c871d5c358accadc632a27b4485a68382d1f Mon Sep 17 00:00:00 2001 From: nicolas Date: Wed, 27 May 2026 09:31:49 -0300 Subject: [PATCH] fix: separate screen-only logging from file logging - Add log_write_screen() for status/stats output (stderr only) - Change STATUS line to use log_write_screen (not in log file) - SIGNAL, ORDER, FILL, FILLED/FAILED still go to both screen and log file - Log file at /tmp/engine.log --- src/evaluate.c | 2 +- src/log.c | 8 ++++++++ src/log.h | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/evaluate.c b/src/evaluate.c index 0505d1e..0e699f2 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -170,7 +170,7 @@ bool evaluate_symbol(evaluator_t *ev, uint16_t symbol_idx, int64_t t_sock_arrive int64_t now = now_ms(); if (now - last_status_ms >= 30000) { last_status_ms = now; - log_write("[STATUS] evals=%lu signals=%lu " + log_write_screen("[STATUS] evals=%lu signals=%lu " "best=%.2f bps (%s) | %u triangles\n", (unsigned long)ev->stats.triangles_evaluated, (unsigned long)ev->stats.signals_fired, diff --git a/src/log.c b/src/log.c index 99e56cb..e19ccaf 100644 --- a/src/log.c +++ b/src/log.c @@ -106,3 +106,11 @@ void log_write(const char *fmt, ...) { write(log_pipe[1], buf, (size_t)total); } } + +/* Write to stderr only — skip the log file. */ +void log_write_screen(const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); +} diff --git a/src/log.h b/src/log.h index 8996773..fd5882d 100644 --- a/src/log.h +++ b/src/log.h @@ -9,10 +9,14 @@ void log_init(void); /* Shut down the writer thread and close the pipe. */ void log_shutdown(void); -/* Write a formatted log line to stderr with timestamp and newline. +/* Write a formatted log line to stderr AND log file (if configured). * Non-blocking after log_init(); falls back to synchronous fprintf. */ void log_write(const char *fmt, ...) __attribute__((format(printf, 1, 2))); +/* Write to stderr ONLY (skip log file). For status/stats that shouldn't + * clutter the execution log file. */ +void log_write_screen(const char *fmt, ...) __attribute__((format(printf, 1, 2))); + /* Set a log file path. Must be called before the first log_write. */ void log_set_file(const char *path);