|
#include "debuglogger.h"
std::string log_to_file_ex::filename_ = "";
typedef std::basic_ostream<TCHAR> stream_type;
stream_type &operator<<(stream_type &log, const std::exception &text)
{
log << text.what();
return log;
}
class TestClass
{
public:
TestClass(int intvalue, double doublevalue) : intvalue_(intvalue), doublevalue_(doublevalue)
{
}
friend stream_type& operator<<(stream_type&, const TestClass &);
private:
int intvalue_;
double doublevalue_;
};
stream_type& operator<<(stream_type&log, const TestClass &tc)
{
log << _T("TestClass(") << tc.intvalue_ << _T(", ") << tc.doublevalue_ << _T(")");
return log;
}
int main(int argc, TCHAR* argv[])
{
try
{
TestClass tc(42, 0.815);
CTXLOG(_T("main()")) << _T("Hello debug log! ") << tc << std::endl;
CTXLOG(_T("main()")) << _T("Only a context message!\n");
RAWLOG() << _T("Without a context!\n");
FileDebugLogger().get() << "This is a simple file logger!" << std::endl;
log_to_file_ex f;
f.setFilename("d:\\temp\\debugex.log");
FileDebugLoggerEx().get() << "This is a file logger!" << std::endl;
}
catch(std::exception &ex)
{
CTXLOG(_T("main()")) << _T("There is a serious problem! (") << ex << _T(")") << std::endl;
}
return 0;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.