Code: Select all
struct wxMyLogException
{
public:
wxMyLogException(time_t ts, const wxChar* msg, wxLogLevel level = (wxLogLevel)-1)
{
this->ts = ts;
this->level = level;
this->msg = msg;
}
time_t ts;
wxLogLevel level;
wxString msg;
};
class wxMyLog: public wxLog
{
private:
public:
virtual void DoLog(wxLogLevel level, const wxChar *msg, time_t timestamp)
{
throw wxMyLogException(timestamp, msg, level);
}
virtual void DoLogString(const wxChar *msg, time_t timestamp)
{
throw wxMyLogException(timestamp, msg);
}
};
Code: Select all
bool MyApp::OnInit()
{
wxLog::SetActiveTarget(&m_log)
}
Code: Select all
try
{
// Operations that may raise wxLog messages
}
catch(wxMyLogException& e)
{
wxDateTime ts(e.ts);
string s;
s.Printf(_("%s:\r\n %s"), ts.Format().c_str(), e.msg.c_str());
wxMessageBox(s);
}