// Created: 29/01/98
// RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
-// Licence: wxWindows license
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
IMPLEMENT_LOG_FUNCTION(Info)
IMPLEMENT_LOG_FUNCTION(Status)
+void wxSafeShowMessage(const wxString& title, const wxString& text)
+{
+#ifdef __WINDOWS__
+ ::MessageBox(NULL, text, title, MB_OK | MB_ICONSTOP);
+#else
+ wxFprintf(stderr, _T("%s: %s\n"), title.c_str(), text.c_str());
+#endif
+}
+
// fatal errors can't be suppressed nor handled by the custom log target and
// always terminate the program
void wxVLogFatalError(const wxChar *szFormat, va_list argptr)
{
wxVsnprintf(s_szBuf, s_szBufSize, szFormat, argptr);
-#if wxUSE_GUI
- wxMessageBox(s_szBuf, _("Fatal Error"), wxID_OK | wxICON_STOP);
-#else
- fprintf(stderr, _("Fatal error: %s\n"), s_szBuf);
-#endif
+ wxSafeShowMessage(_T("Fatal Error"), s_szBuf);
abort();
}
p += 2;
wxVsnprintf(p, len, szFormat, argptr);
-
+
wxLog::OnLog(wxLOG_Trace, s_szBuf, time(NULL));
}
}
wxLog::wxLog()
{
- m_bHasMessages = FALSE;
}
-wxChar *wxLog::SetLogBuffer( wxChar *buf, size_t size = 0 )
+wxChar *wxLog::SetLogBuffer( wxChar *buf, size_t size)
{
wxChar *oldbuf = s_szBuf;
void wxLog::Flush()
{
- // remember that we don't have any more messages to show
- m_bHasMessages = FALSE;
+ // nothing to do here
}
// ----------------------------------------------------------------------------
m_fp = fp;
}
-#if defined(__WXMAC__) && !defined(__DARWIN__) && (__MWERKS__ > 0x5300)
+#if defined(__WXMAC__) && !defined(__DARWIN__) && defined(__MWERKS__) && (__MWERKS__ >= 0x2400)
-#if !TARGET_API_MAC_CARBON
// MetroNub stuff doesn't seem to work in CodeWarrior 5.3 Carbon builds...
#ifndef __MetroNubUtils__
result = (inVersion <= block->apiHiVersion);
}
- return result;
+ return result;
}
/* ---------------------------------------------------------------------------
}
#endif
-#endif // !TARGET_API_MAC_CARBON
-
-#endif // defined(__WXMAC__) && !defined(__DARWIN__) && (__MWERKS__ > 0x5300)
+#endif // defined(__WXMAC__) && !defined(__DARWIN__) && (__MWERKS__ >= 0x2400)
void wxLogStderr::DoLogString(const wxChar *szString, time_t WXUNUSED(t))
{
fflush(m_fp);
// under Windows, programs usually don't have stderr at all, so show the
- // messages also under debugger - unless it's a console program
+ // messages also under debugger (unless it's a console program which does
+ // have stderr or unless this is a file logger which doesn't use stderr at
+ // all)
#if defined(__WXMSW__) && wxUSE_GUI && !defined(__WXMICROWIN__)
- str += wxT("\r\n") ;
- OutputDebugString(str.c_str());
+ if ( m_fp == stderr )
+ {
+ str += wxT("\r\n") ;
+ OutputDebugString(str.c_str());
+ }
#endif // MSW
+
#if defined(__WXMAC__) && !defined(__DARWIN__) && wxUSE_GUI
Str255 pstr ;
- strcpy( (char*) pstr , str.c_str() ) ;
- strcat( (char*) pstr , ";g" ) ;
- c2pstr( (char*) pstr ) ;
+ wxString output = str + wxT(";g") ;
+ wxMacStringToPascal( output.c_str() , pstr ) ;
Boolean running = false ;
-#if !TARGET_API_MAC_CARBON && (__MWERKS__ > 0x5300)
+#if defined(__MWERKS__) && (__MWERKS__ >= 0x2400)
if ( IsMWDebuggerRunning() && AmIBeingMWDebugged() )
{
// ----------------------------------------------------------------------------
#if wxUSE_STD_IOSTREAM
+#include "wx/ioswrap.h"
wxLogStream::wxLogStream(wxSTD ostream *ostr)
{
if ( ostr == NULL )
wxLogChain::wxLogChain(wxLog *logger)
{
+ m_bPassMessages = TRUE;
+
m_logNew = logger;
m_logOld = wxLog::SetActiveTarget(this);
}
-void wxLogChain::SetLog(wxLog *logger)
+wxLogChain::~wxLogChain()
{
+ delete m_logOld;
+
if ( m_logNew != this )
delete m_logNew;
+}
- wxLog::SetActiveTarget(logger);
+void wxLogChain::SetLog(wxLog *logger)
+{
+ if ( m_logNew != this )
+ delete m_logNew;
m_logNew = logger;
}
if ( m_logOld )
m_logOld->Flush();
- // be careful to avoid inifinite recursion
+ // be careful to avoid infinite recursion
if ( m_logNew && m_logNew != this )
m_logNew->Flush();
}
bool wxLog::ms_bAutoCreate = TRUE;
bool wxLog::ms_bVerbose = FALSE;
+wxLogLevel wxLog::ms_logLevel = wxLOG_Max; // log everything by default
+
size_t wxLog::ms_suspendCount = 0;
#if wxUSE_GUI