Thanks high_flyer (but I dont understand you)
This is my function (for strings):
W_debug& W_debug::operator << (const char * data) {
if (strcmp (data,"")==0)
{ switch (log_file_mode)
{
case 0:
qDebug()<<QString().fromStdString(os.str());
break;
case 1:
log_file->write(os.str());
break;
case 2:
my_window->add(os.str()); // another custom class
break;
}
os.clear(); os.str("");
}
else
{ os<<data; return *this; } // os is a std::stream
}
W_debug& W_debug::operator << (const char * data) {
if (strcmp (data,"")==0)
{ switch (log_file_mode)
{
case 0:
qDebug()<<QString().fromStdString(os.str());
break;
case 1:
log_file->write(os.str());
break;
case 2:
my_window->add(os.str()); // another custom class
break;
}
os.clear(); os.str("");
}
else
{ os<<data; return *this; } // os is a std::stream
}
To copy to clipboard, switch view to plain text mode
As you can see I use "" detection to resolve that the user has ended the call.
If not, I cannot to have more than one message per line.
(because, regardless the 'log_mode' method I use, every << will emit the result )
So the question are unresolved, (or I dont understand your explanation) :
If I have w_debug()<<"a word"<< data1<<"a word"<< data2;
How can I know the end of << feeding .,
Thanks
Mcosta : thanks, but I need more control over the messages and QtGlobal::qInstallMsgHandler() perhaps is useful, but I want to develop my own 'w_debug'.
Bookmarks