+// ----------------------------------------------------------------------------
+// wxLogChain
+// ----------------------------------------------------------------------------
+
+wxLogChain::wxLogChain(wxLog *logger)
+{
+ m_bPassMessages = true;
+
+ m_logNew = logger;
+ m_logOld = wxLog::SetActiveTarget(this);
+}
+
+wxLogChain::~wxLogChain()
+{
+ delete m_logOld;
+
+ if ( m_logNew != this )
+ delete m_logNew;
+}
+
+void wxLogChain::SetLog(wxLog *logger)
+{
+ if ( m_logNew != this )
+ delete m_logNew;
+
+ m_logNew = logger;
+}
+
+void wxLogChain::Flush()
+{
+ if ( m_logOld )
+ m_logOld->Flush();
+
+ // be careful to avoid infinite recursion
+ if ( m_logNew && m_logNew != this )
+ m_logNew->Flush();
+}
+
+void wxLogChain::DoLog(wxLogLevel level, const wxString& szString, time_t t)
+{
+ // let the previous logger show it
+ if ( m_logOld && IsPassingMessages() )
+ {
+ // bogus cast just to access protected DoLog
+ ((wxLogChain *)m_logOld)->DoLog(level, szString, t);
+ }
+
+ if ( m_logNew && m_logNew != this )
+ {
+ // as above...
+ ((wxLogChain *)m_logNew)->DoLog(level, szString, t);
+ }
+}
+
+#ifdef __VISUALC__
+ // "'this' : used in base member initializer list" - so what?
+ #pragma warning(disable:4355)
+#endif // VC++
+
+// ----------------------------------------------------------------------------
+// wxLogInterposer
+// ----------------------------------------------------------------------------
+
+wxLogInterposer::wxLogInterposer()
+ : wxLogChain(this)
+{
+}
+
+// ----------------------------------------------------------------------------
+// wxLogInterposerTemp
+// ----------------------------------------------------------------------------
+
+wxLogInterposerTemp::wxLogInterposerTemp()
+ : wxLogChain(this)
+{
+ DetachOldLog();
+}
+
+#ifdef __VISUALC__
+ #pragma warning(default:4355)
+#endif // VC++
+