Added DetachOldLog to avoid destruction of old log target
Renamed wxLogPassThrough to wxLogInterposer Added wxLogInterposerTemp git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46580 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -434,6 +434,13 @@ target but the log messages are also passed to the previous log target if any.
|
|||||||
|
|
||||||
Destroys the previous log target.
|
Destroys the previous log target.
|
||||||
|
|
||||||
|
\membersection{wxLogChain::DetachOldLog}\label{wxlogchaindetacholdlog}
|
||||||
|
|
||||||
|
\func{void}{DetachOldLog}{\void}
|
||||||
|
|
||||||
|
Detaches the old log target so it won't be destroyed when the wxLogChain object
|
||||||
|
is destroyed.
|
||||||
|
|
||||||
\membersection{wxLogChain::GetOldLog}\label{wxlogchaingetoldlog}
|
\membersection{wxLogChain::GetOldLog}\label{wxlogchaingetoldlog}
|
||||||
|
|
||||||
\constfunc{wxLog *}{GetOldLog}{\void}
|
\constfunc{wxLog *}{GetOldLog}{\void}
|
||||||
@@ -564,19 +571,47 @@ Suspends logging.
|
|||||||
|
|
||||||
Resumes logging.
|
Resumes logging.
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogPassThrough %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogInterposer %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
\section{\class{wxLogPassThrough}}\label{wxlogpassthrough}
|
\section{\class{wxLogInterposer}}\label{wxloginterposer}
|
||||||
|
|
||||||
A special version of \helpref{wxLogChain}{wxlogchain} which uses itself as the
|
A special version of \helpref{wxLogChain}{wxlogchain} which uses itself as the
|
||||||
new log target. Maybe more clearly, it means that this is a log target which
|
new log target. It forwards log messages to the previously installed one in addition to
|
||||||
forwards the log messages to the previously installed one in addition to
|
|
||||||
processing them itself.
|
processing them itself.
|
||||||
|
|
||||||
Unlike \helpref{wxLogChain}{wxlogchain} which is usually used directly as is,
|
Unlike \helpref{wxLogChain}{wxlogchain} which is usually used directly as is,
|
||||||
this class must be derived from to implement \helpref{DoLog}{wxlogdolog}
|
this class must be derived from to implement \helpref{DoLog}{wxlogdolog}
|
||||||
and/or \helpref{DoLogString}{wxlogdologstring} methods.
|
and/or \helpref{DoLogString}{wxlogdologstring} methods.
|
||||||
|
|
||||||
|
wxLogInterposer destroys the previous log target in its destructor. If you
|
||||||
|
don't want this to happen, use wxLogInterposerTemp instead.
|
||||||
|
|
||||||
|
\wxheading{Derived from}
|
||||||
|
|
||||||
|
\helpref{wxLogChain}{wxlogchain}
|
||||||
|
|
||||||
|
\wxheading{Include files}
|
||||||
|
|
||||||
|
<wx/log.h>
|
||||||
|
|
||||||
|
\latexignore{\rtfignore{\wxheading{Members}}}
|
||||||
|
|
||||||
|
\membersection{wxLogInterposer::wxLogInterposer}\label{wxloginterposerctor}
|
||||||
|
|
||||||
|
The default constructor installs this object as the current active log target.
|
||||||
|
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogInterposerTemp %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
|
\section{\class{wxLogInterposerTemp}}\label{wxloginterposertemp}
|
||||||
|
|
||||||
|
A special version of \helpref{wxLogChain}{wxlogchain} which uses itself as the
|
||||||
|
new log target. It forwards log messages to the previously installed one in addition to
|
||||||
|
processing them itself. Unlike \helpref{wxLogInterposer}{wxloginterposer}, it doesn't
|
||||||
|
delete the old target which means it can be used to temporarily redirect log output.
|
||||||
|
|
||||||
|
As per wxLogInterposer, this class must be derived from to implement \helpref{DoLog}{wxlogdolog}
|
||||||
|
and/or \helpref{DoLogString}{wxlogdologstring} methods.
|
||||||
|
|
||||||
\wxheading{Derived from}
|
\wxheading{Derived from}
|
||||||
|
|
||||||
\helpref{wxLogChain}{wxlogchain}
|
\helpref{wxLogChain}{wxlogchain}
|
||||||
@@ -587,9 +622,9 @@ and/or \helpref{DoLogString}{wxlogdologstring} methods.
|
|||||||
|
|
||||||
\latexignore{\rtfignore{\wxheading{Members}}}
|
\latexignore{\rtfignore{\wxheading{Members}}}
|
||||||
|
|
||||||
\membersection{wxLogPassThrough::wxLogPassThrough}\label{wxlogpassthroughctor}
|
\membersection{wxLogInterposerTemp::wxLogInterposerTemp}\label{wxloginterposertempctor}
|
||||||
|
|
||||||
Default ctor installs this object as the current active log target.
|
The default constructor installs this object as the current active log target.
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogStderr %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wxLogStderr %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
@@ -693,7 +728,7 @@ them normally by showing the standard log dialog.
|
|||||||
|
|
||||||
\wxheading{Derived from}
|
\wxheading{Derived from}
|
||||||
|
|
||||||
\helpref{wxLogPassThrough}{wxlogpassthrough}
|
\helpref{wxLogInterposer}{wxloginterposer}
|
||||||
|
|
||||||
\wxheading{Include files}
|
\wxheading{Include files}
|
||||||
|
|
||||||
|
@@ -8,7 +8,8 @@ Classes: \helpref{wxLog}{wxlog},\\
|
|||||||
\helpref{wxLogGui}{wxloggui},\\
|
\helpref{wxLogGui}{wxloggui},\\
|
||||||
\helpref{wxLogNull}{wxlognull},\\
|
\helpref{wxLogNull}{wxlognull},\\
|
||||||
\helpref{wxLogChain}{wxlogchain},\\
|
\helpref{wxLogChain}{wxlogchain},\\
|
||||||
\helpref{wxLogPassThrough}{wxlogpassthrough},\\
|
\helpref{wxLogInterposer}{wxloginterposer},\\
|
||||||
|
\helpref{wxLogInterposerTemp}{wxloginterposertemp},\\
|
||||||
\helpref{wxStreamToTextRedirector}{wxstreamtotextredirector}
|
\helpref{wxStreamToTextRedirector}{wxstreamtotextredirector}
|
||||||
|
|
||||||
This is a general overview of logging classes provided by wxWidgets. The word
|
This is a general overview of logging classes provided by wxWidgets. The word
|
||||||
@@ -166,6 +167,6 @@ reasons it is unwanted, just use this construction:
|
|||||||
|
|
||||||
The log targets can also be combined: for example you may wish to redirect the
|
The log targets can also be combined: for example you may wish to redirect the
|
||||||
messages somewhere else (for example, to a log file) but also process them as
|
messages somewhere else (for example, to a log file) but also process them as
|
||||||
normally. For this the \helpref{wxLogChain}{wxlogchain} and
|
normally. For this the \helpref{wxLogChain}{wxlogchain}, \helpref{wxLogInterposer}{wxloginterposer} and\rtfsp
|
||||||
\helpref{wxLogPassThrough}{wxlogpassthrough} can be used.
|
\helpref{wxLogInterposerTemp}{wxloginterposertemp} can be used.
|
||||||
|
|
||||||
|
@@ -439,6 +439,9 @@ public:
|
|||||||
// override base class version to flush the old logger as well
|
// override base class version to flush the old logger as well
|
||||||
virtual void Flush();
|
virtual void Flush();
|
||||||
|
|
||||||
|
// call to avoid destroying the old log target
|
||||||
|
void DetachOldLog() { m_logOld = NULL; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// pass the chain to the old logger if needed
|
// pass the chain to the old logger if needed
|
||||||
virtual void DoLog(wxLogLevel level, const wxString& szString, time_t t);
|
virtual void DoLog(wxLogLevel level, const wxString& szString, time_t t);
|
||||||
@@ -457,13 +460,28 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// a chain log target which uses itself as the new logger
|
// a chain log target which uses itself as the new logger
|
||||||
class WXDLLIMPEXP_BASE wxLogPassThrough : public wxLogChain
|
|
||||||
|
#define wxLogPassThrough wxLogInterposer
|
||||||
|
|
||||||
|
class WXDLLIMPEXP_BASE wxLogInterposer : public wxLogChain
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxLogPassThrough();
|
wxLogInterposer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_NO_COPY_CLASS(wxLogPassThrough)
|
DECLARE_NO_COPY_CLASS(wxLogInterposer)
|
||||||
|
};
|
||||||
|
|
||||||
|
// a temporary interposer which doesn't destroy the old log target
|
||||||
|
// (calls DetachOldLog)
|
||||||
|
|
||||||
|
class WXDLLIMPEXP_BASE wxLogInterposerTemp : public wxLogChain
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxLogInterposerTemp();
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_NO_COPY_CLASS(wxLogInterposerTemp)
|
||||||
};
|
};
|
||||||
|
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
|
@@ -865,20 +865,30 @@ void wxLogChain::DoLog(wxLogLevel level, const wxString& szString, time_t t)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// wxLogPassThrough
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifdef __VISUALC__
|
#ifdef __VISUALC__
|
||||||
// "'this' : used in base member initializer list" - so what?
|
// "'this' : used in base member initializer list" - so what?
|
||||||
#pragma warning(disable:4355)
|
#pragma warning(disable:4355)
|
||||||
#endif // VC++
|
#endif // VC++
|
||||||
|
|
||||||
wxLogPassThrough::wxLogPassThrough()
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxLogInterposer
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxLogInterposer::wxLogInterposer()
|
||||||
: wxLogChain(this)
|
: wxLogChain(this)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxLogInterposerTemp
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxLogInterposerTemp::wxLogInterposerTemp()
|
||||||
|
: wxLogChain(this)
|
||||||
|
{
|
||||||
|
DetachOldLog();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __VISUALC__
|
#ifdef __VISUALC__
|
||||||
#pragma warning(default:4355)
|
#pragma warning(default:4355)
|
||||||
#endif // VC++
|
#endif // VC++
|
||||||
|
Reference in New Issue
Block a user