Hi jOan,
if some one has a link to osgConsole where this should be implemented I'm
interested.
I can't find it.
Here's my notes on the subject based on posts by Marco and others.
How-to forward cout and cerr to file:
ofstream log("Message.log");
streambuf* out = cout.rdbuf(log.rdbuf());
streambuf* err = cerr.rdbuf(log.rdbuf());
How-to forward cout and cerr to debugger using custom streambuf:
Post on OSG mailing list by Marco and later patched by Ben D.
#include <streambuf>
void Log(const char *msg)
{
#ifdef _MSC_VER
#ifdef _UNICODE
wchar_t buf[1024];
MultiByteToWideChar(CP_ACP, 0, msg, -1, buf, 1024);
OutputDebugString(buf);
#else
OutputDebugString(msg);
#endif
#endif
}
class OsgMsgTrap : public std::streambuf
{
public:
inline virtual int_type overflow(int_type c =
std::streambuf::traits_type::eof())
{
if (c == std::streambuf::traits_type::eof()) return
std::streambuf::traits_type::not_eof(c);
char str[2];
str[0] = c;
str[1] = 0;
Log(str);
return c;
}
} g_Trap;
void main()
{
// Redirect cout messages (where OSG sends its messages) to our own log
std::cout.rdbuf(&g_Trap);
std::cerr.rdbuf(&g_Trap);
}
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/