about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-06-04 16:54:50 +0200
committerptitSeb <sebastien.chev@gmail.com>2021-06-04 16:54:50 +0200
commitadd55f3cec4e1585d18b44817d40b566c3f88fc7 (patch)
tree285dc2ae70d773aa1eb407e258e4495d5c3d3067 /src
parentc6f6a9ef7249c63ad839fd0642df3a34e15bcf35 (diff)
downloadbox64-add55f3cec4e1585d18b44817d40b566c3f88fc7.tar.gz
box64-add55f3cec4e1585d18b44817d40b566c3f88fc7.zip
Added an option to use stderr for logs
Diffstat (limited to 'src')
-rwxr-xr-xsrc/main.c20
1 files changed, 12 insertions, 8 deletions
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");