Browse code

Output trace messages to stderr, to ensure its flushed.

Török Edvin authored on 2009/12/12 01:09:33
Showing 1 changed files
... ...
@@ -71,16 +71,16 @@ static void tracehook(struct cli_bc_ctx *ctx, unsigned event)
71 71
 	return;
72 72
     switch (event) {
73 73
 	case trace_func:
74
-	    printf("[trace] %s:%u:%u -> %s:%u:%u Entered function %s\n",
74
+	    fprintf(stderr, "[trace] %s:%u:%u -> %s:%u:%u Entered function %s\n",
75 75
 		   dbg_state.file, dbg_state.line, dbg_state.col,
76 76
 		   ctx->file, ctx->line, ctx->col, ctx->scope);
77 77
 	    dbg_state.scope = ctx->scope;
78 78
 	    break;
79 79
 	case trace_param:
80
-	    printf("[trace] function parameter:\n");
80
+	    fprintf(stderr, "[trace] function parameter:\n");
81 81
 	    return;
82 82
 	case trace_scope:
83
-	    printf("[trace] %s:%u:%u -> %s:%u:%u\n",
83
+	    fprintf(stderr, "[trace] %s:%u:%u -> %s:%u:%u\n",
84 84
 		   dbg_state.file, dbg_state.line, dbg_state.col,
85 85
 		   ctx->file, ctx->line, ctx->col);
86 86
 	    dbg_state.scope = ctx->scope;
... ...
@@ -90,7 +90,7 @@ static void tracehook(struct cli_bc_ctx *ctx, unsigned event)
90 90
 	    if (dbg_state.showline)
91 91
 		cli_bytecode_debug_printsrc(ctx);
92 92
 	    else
93
-		printf("[trace] %s:%u:%u\n",
93
+		fprintf(stderr, "[trace] %s:%u:%u\n",
94 94
 		       dbg_state.file, dbg_state.line, dbg_state.col);
95 95
 	    break;
96 96
 	default:
... ...
@@ -103,12 +103,12 @@ static void tracehook(struct cli_bc_ctx *ctx, unsigned event)
103 103
 
104 104
 static void tracehook_op(struct cli_bc_ctx *ctx, const char *op)
105 105
 {
106
-    printf("[trace] %s\n", op);
106
+    fprintf(stderr, "[trace] %s\n", op);
107 107
 }
108 108
 
109 109
 static void tracehook_val(struct cli_bc_ctx *ctx, const char *name, uint32_t value)
110 110
 {
111
-    printf("[trace] %s = %u\n", name, value);
111
+    fprintf(stderr, "[trace] %s = %u\n", name, value);
112 112
 }
113 113
 
114 114
 int main(int argc, char *argv[])