I have a Trace.h file which is include in pretty much all my files, which contains the following:
Basically, the idea is I can log stuff to a file as my program runs.Code:#ifndef TRACE_H_INCLUDED
#define TRACE_H_INCLUDED
#include <iostream>
#include <fstream>
static std::ofstream log_stream("output.log");
#define TRACE(ARG) if(true){log_stream << __FILE << " at line " << __LINE << ARG << std::endl;} else void(0)
#endif // TRACE_H_INCLUDED
The problem is that after running my program, I realize that a good amount of my traces are missing, most are out of order, and finally, a lot of them are missing the beginning or end of the message, like this:
What am I doing wrong? I thought std::endl was supposed to flush my stream, doesn't that mean this shouldn't happen?Code:/main.cpp at line 28 there
ne 33 here
/EnColor.h at line 33 hello
Do I have a broken declaration of log_stream, and actually have several handles on the same file?
Is this an ofstream problem, or what? What would you guys do?
PS: Codeblocks with mingw on winxp32
PS2, replacing log_stream with the standard std::cout works fine, but that is not what I want

