#ifndef __LOG1_H__
#define __LOG1_H__
#include <string>
#include <stdio.h>
class Log
{
public:
Log(){};
~Log();
std::ostringstream& Get();
protected:
std::ostringstream os;
};
inline Log::~Log()
{
os << std::endl;
fprintf(stderr, "%s", os.str().c_str());
fflush(stderr);
}
inline std::ostringstream& Log::Get()
{
os << " " << ": ";
return os;
}
#define log() Log().Get()
#endif //__LOG_H__
test.cpp:
log() << "A loop with " << count << " iterations";
No comments:
Post a Comment