about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xUSAGE.md1
-rwxr-xr-xsrc/main.c20
2 files changed, 13 insertions, 8 deletions
diff --git a/USAGE.md b/USAGE.md
index 52483d11..27afc08d 100755
--- a/USAGE.md
+++ b/USAGE.md
@@ -31,6 +31,7 @@ Enables/Disables the logging of `dlsym` errors.
 #### BOX64_TRACE_FILE

 Send all log and trace to a file instead of `stdout`

 Also, if name contains `%pid` then this is replaced by the actual PID of box64 instance

+Use `stderr` to use this instead of default `stdout` 

 

 #### BOX64_TRACE

 Only on build with trace enabled. Trace allow the logging of all instruction executed, along with register dump

diff --git a/src/main.c b/src/main.c
index c7b55380..66209f04 100755
--- a/src/main.c
+++ b/src/main.c
@@ -89,13 +89,17 @@ void openFTrace()
         ftrace_has_pid = 1;
     }
     if(p) {
-        ftrace = fopen(p, "w");
-        if(!ftrace) {
-            ftrace = stdout;
-            printf_log(LOG_INFO, "Cannot open trace file \"%s\" for writing (error=%s)\n", p, strerror(errno));
-        } else {
-            if(!box64_nobanner)
-                printf("BOX64 Trace redirected to \"%s\"\n", p);
+        if(!strcmp(p, "stderr"))
+            ftrace = stderr;
+        else {
+            ftrace = fopen(p, "w");
+            if(!ftrace) {
+                ftrace = stdout;
+                printf_log(LOG_INFO, "Cannot open trace file \"%s\" for writing (error=%s)\n", p, strerror(errno));
+            } else {
+                if(!box64_nobanner)
+                    printf("BOX64 Trace redirected to \"%s\"\n", p);
+            }
         }
     }
 }
@@ -464,7 +468,7 @@ void PrintHelp() {
     printf(" BOX64_DYNAREC_TRACE with 0/1 to disable or enable Trace on generated code too\n");
 #endif
 #endif
-    printf(" BOX64_TRACE_FILE with FileName to redirect logs in a file");
+    printf(" BOX64_TRACE_FILE with FileName to redirect logs in a file (or stderr to use stderr instead of stdout)");
     printf(" BOX64_DLSYM_ERROR with 1 to log dlsym errors\n");
     printf(" BOX64_LOAD_ADDR=0xXXXXXX try to load at 0xXXXXXX main binary (if binary is a PIE)\n");
     printf(" BOX64_NOSIGSEGV=1 to disable handling of SigSEGV\n");