mirror of
https://github.com/gechandesu/runcmd.git
synced 2026-06-02 21:28:04 +03:00
dbg: Better logging, -d runcmd_trace_file=FILEPATH support
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user