dbg: Better logging, -d runcmd_trace_file=FILEPATH support

This commit is contained in:
ge
2026-06-01 00:01:32 +03:00
parent 5636f29acd
commit ac516c7b6c
3 changed files with 29 additions and 13 deletions
+10 -1
View File
@@ -1,6 +1,15 @@
module runcmd
import os
@[if runcmd_trace ?]
fn printdbg(s string) {
eprintln('runcmd[pid=${v_getpid()}]: ${s}')
text := 'runcmd[pid=${v_getpid()}]: ${s}'
eprintln(text)
trace_file := $d('runcmd_trace_file', '')
if trace_file != '' {
file := os.open_append(trace_file) or { return }
file.write_string(text + '\n') or {}
file.flush()
}
}