void trace_out(const char *fmt, ... ) { static FILE *trace_file = 0L; time_t now = time(0L); char date_string[23]; strftime(date_string, 256, "%Y-%m-%d %H.%M.%S", localtime(&now)); if (!trace_file) { trace_file = fopen("trace.txt", "a+"); if (!trace_file) return; } va_list v; va_start(v, fmt); fprintf(trace_file, "%s |", date_string); vfprintf(trace_file, fmt, v); fputc('\n', trace_file); fflush(trace_file); }