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
This commit is contained in:
nicolas 2026-05-27 09:31:49 -03:00
parent 46084de4b2
commit 8739c871d5
3 changed files with 14 additions and 2 deletions

View File

@ -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,

View File

@ -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);
}

View File

@ -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);