Merge branch 'log-encoding'
See https://github.com/wxWidgets/wxWidgets/pull/552 Closes #17385.
This commit is contained in:
@@ -61,6 +61,7 @@ class WXDLLIMPEXP_FWD_BASE wxObject;
|
||||
|
||||
#include "wx/dynarray.h"
|
||||
#include "wx/hashmap.h"
|
||||
#include "wx/msgout.h"
|
||||
|
||||
#if wxUSE_THREADS
|
||||
#include "wx/thread.h"
|
||||
@@ -716,29 +717,31 @@ private:
|
||||
|
||||
|
||||
// log everything to a "FILE *", stderr by default
|
||||
class WXDLLIMPEXP_BASE wxLogStderr : public wxLog
|
||||
class WXDLLIMPEXP_BASE wxLogStderr : public wxLog,
|
||||
private wxMessageOutputStderr
|
||||
{
|
||||
public:
|
||||
// redirect log output to a FILE
|
||||
wxLogStderr(FILE *fp = NULL);
|
||||
wxLogStderr(FILE *fp = NULL,
|
||||
const wxMBConv &conv = wxConvWhateverWorks);
|
||||
|
||||
protected:
|
||||
// implement sink function
|
||||
virtual void DoLogText(const wxString& msg) wxOVERRIDE;
|
||||
|
||||
FILE *m_fp;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxLogStderr);
|
||||
};
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
|
||||
// log everything to an "ostream", cerr by default
|
||||
class WXDLLIMPEXP_BASE wxLogStream : public wxLog
|
||||
class WXDLLIMPEXP_BASE wxLogStream : public wxLog,
|
||||
private wxMessageOutputWithConv
|
||||
{
|
||||
public:
|
||||
// redirect log output to an ostream
|
||||
wxLogStream(wxSTD ostream *ostr = (wxSTD ostream *) NULL);
|
||||
wxLogStream(wxSTD ostream *ostr = (wxSTD ostream *) NULL,
|
||||
const wxMBConv& conv = wxConvWhateverWorks);
|
||||
|
||||
protected:
|
||||
// implement sink function
|
||||
@@ -746,6 +749,8 @@ protected:
|
||||
|
||||
// using ptr here to avoid including <iostream.h> from this file
|
||||
wxSTD ostream *m_ostr;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxLogStream);
|
||||
};
|
||||
|
||||
#endif // wxUSE_STD_IOSTREAM
|
||||
|
@@ -58,22 +58,51 @@ private:
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// implementation which sends output to stderr or specified file
|
||||
// helper mix-in for output targets that can use difference encodings
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_BASE wxMessageOutputStderr : public wxMessageOutput
|
||||
class WXDLLIMPEXP_BASE wxMessageOutputWithConv
|
||||
{
|
||||
public:
|
||||
wxMessageOutputStderr(FILE *fp = stderr) : m_fp(fp) { }
|
||||
|
||||
virtual void Output(const wxString& str) wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
explicit wxMessageOutputWithConv(const wxMBConv& conv)
|
||||
: m_conv(conv.Clone())
|
||||
{
|
||||
}
|
||||
|
||||
~wxMessageOutputWithConv()
|
||||
{
|
||||
delete m_conv;
|
||||
}
|
||||
|
||||
// return the string with "\n" appended if it doesn't already terminate
|
||||
// with it (in which case it's returned unchanged)
|
||||
wxString AppendLineFeedIfNeeded(const wxString& str);
|
||||
|
||||
// Prepare the given string for output by appending a new line to it, if
|
||||
// necessary, and converting it to a narrow string using our conversion
|
||||
// object.
|
||||
wxCharBuffer PrepareForOutput(const wxString& str);
|
||||
|
||||
const wxMBConv* const m_conv;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// implementation which sends output to stderr or specified file
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_BASE wxMessageOutputStderr : public wxMessageOutput,
|
||||
protected wxMessageOutputWithConv
|
||||
{
|
||||
public:
|
||||
wxMessageOutputStderr(FILE *fp = stderr,
|
||||
const wxMBConv &conv = wxConvWhateverWorks);
|
||||
|
||||
virtual void Output(const wxString& str) wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
FILE *m_fp;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxMessageOutputStderr);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user