added wxLogBuffer which collects all log messages in a string buffer
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34556 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -288,11 +288,31 @@ private:
|
|||||||
// "trivial" derivations of wxLog
|
// "trivial" derivations of wxLog
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// log everything to a buffer
|
||||||
|
class WXDLLIMPEXP_BASE wxLogBuffer : public wxLog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxLogBuffer() { }
|
||||||
|
|
||||||
|
// get the string contents with all messages logged
|
||||||
|
const wxString& GetBuffer() const { return m_str; }
|
||||||
|
|
||||||
|
// show the buffer contents to the user in the best possible way (this uses
|
||||||
|
// wxMessageOutputMessageBox) and clear it
|
||||||
|
virtual void Flush();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void DoLogString(const wxChar *szString, time_t t);
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxString m_str;
|
||||||
|
|
||||||
|
DECLARE_NO_COPY_CLASS(wxLogBuffer)
|
||||||
|
};
|
||||||
|
|
||||||
// log everything to a "FILE *", stderr by default
|
// log everything to a "FILE *", stderr by default
|
||||||
class WXDLLIMPEXP_BASE wxLogStderr : public wxLog
|
class WXDLLIMPEXP_BASE wxLogStderr : public wxLog
|
||||||
{
|
{
|
||||||
DECLARE_NO_COPY_CLASS(wxLogStderr)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// redirect log output to a FILE
|
// redirect log output to a FILE
|
||||||
wxLogStderr(FILE *fp = (FILE *) NULL);
|
wxLogStderr(FILE *fp = (FILE *) NULL);
|
||||||
@@ -302,6 +322,8 @@ protected:
|
|||||||
virtual void DoLogString(const wxChar *szString, time_t t);
|
virtual void DoLogString(const wxChar *szString, time_t t);
|
||||||
|
|
||||||
FILE *m_fp;
|
FILE *m_fp;
|
||||||
|
|
||||||
|
DECLARE_NO_COPY_CLASS(wxLogStderr)
|
||||||
};
|
};
|
||||||
|
|
||||||
#if wxUSE_STD_IOSTREAM
|
#if wxUSE_STD_IOSTREAM
|
||||||
|
@@ -522,6 +522,22 @@ void wxLog::Flush()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxLogBuffer implementation
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxLogBuffer::Flush()
|
||||||
|
{
|
||||||
|
wxMessageOutputBest out;
|
||||||
|
out.Printf(_T("%s"), m_str.c_str());
|
||||||
|
m_str.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxLogBuffer::DoLogString(const wxChar *szString, time_t WXUNUSED(t))
|
||||||
|
{
|
||||||
|
m_str << szString << _T("\n");
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxLogStderr class implementation
|
// wxLogStderr class implementation
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user