]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/log.cpp
fixing the shrinking embedded controls
[wxWidgets.git] / src / common / log.cpp
index c4d3ef212b5744023f02a31066af368d2bf0f397..e6690b652a6be8f489b95e50266c80982c36bdb2 100644 (file)
@@ -37,6 +37,7 @@
 #endif //WX_PRECOMP
 
 #include "wx/apptrait.h"
+#include "wx/datetime.h"
 #include "wx/file.h"
 #include "wx/msgout.h"
 #include "wx/textfile.h"
 // ----------------------------------------------------------------------------
 
 // generic log function
-void wxVLogGeneric(wxLogLevel level, const wxChar *szFormat, va_list argptr)
+void wxVLogGeneric(wxLogLevel level, const wxString& format, va_list argptr)
 {
     if ( wxLog::IsEnabled() ) {
-        wxLog::OnLog(level, wxString::FormatV(szFormat, argptr), time(NULL));
+        wxLog::OnLog(level, wxString::FormatV(format, argptr), time(NULL));
     }
 }
 
-void wxLogGeneric(wxLogLevel level, const wxChar *szFormat, ...)
+void wxDoLogGeneric(wxLogLevel level, const wxChar *szFormat, ...)
 {
     va_list argptr;
     va_start(argptr, szFormat);
@@ -99,15 +100,15 @@ void wxLogGeneric(wxLogLevel level, const wxChar *szFormat, ...)
 }
 
 #define IMPLEMENT_LOG_FUNCTION(level)                               \
-  void wxVLog##level(const wxChar *szFormat, va_list argptr)        \
+  void wxVLog##level(const wxString& format, va_list argptr)        \
   {                                                                 \
     if ( wxLog::IsEnabled() ) {                                     \
       wxLog::OnLog(wxLOG_##level,                                   \
-                   wxString::FormatV(szFormat, argptr), time(NULL));\
+                   wxString::FormatV(format, argptr), time(NULL));  \
     }                                                               \
   }                                                                 \
                                                                     \
-  void wxLog##level(const wxChar *szFormat, ...)                    \
+  void wxDoLog##level(const wxChar *szFormat, ...)                  \
   {                                                                 \
     va_list argptr;                                                 \
     va_start(argptr, szFormat);                                     \
@@ -133,9 +134,9 @@ void wxSafeShowMessage(const wxString& title, const wxString& text)
 
 // 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)
+void wxVLogFatalError(const wxString& format, va_list argptr)
 {
-    wxSafeShowMessage(_T("Fatal Error"), wxString::FormatV(szFormat, argptr));
+    wxSafeShowMessage(_T("Fatal Error"), wxString::FormatV(format, argptr));
 
 #ifdef __WXWINCE__
     ExitThread(3);
@@ -144,7 +145,7 @@ void wxVLogFatalError(const wxChar *szFormat, va_list argptr)
 #endif
 }
 
-void wxLogFatalError(const wxChar *szFormat, ...)
+void wxDoLogFatalError(const wxChar *szFormat, ...)
 {
     va_list argptr;
     va_start(argptr, szFormat);
@@ -156,17 +157,17 @@ void wxLogFatalError(const wxChar *szFormat, ...)
 }
 
 // same as info, but only if 'verbose' mode is on
-void wxVLogVerbose(const wxChar *szFormat, va_list argptr)
+void wxVLogVerbose(const wxString& format, va_list argptr)
 {
     if ( wxLog::IsEnabled() ) {
         if ( wxLog::GetActiveTarget() != NULL && wxLog::GetVerbose() ) {
             wxLog::OnLog(wxLOG_Info,
-                         wxString::FormatV(szFormat, argptr), time(NULL));
+                         wxString::FormatV(format, argptr), time(NULL));
         }
     }
 }
 
-void wxLogVerbose(const wxChar *szFormat, ...)
+void wxDoLogVerbose(const wxChar *szFormat, ...)
 {
     va_list argptr;
     va_start(argptr, szFormat);
@@ -185,7 +186,7 @@ void wxLogVerbose(const wxChar *szFormat, ...)
     }                                                               \
   }                                                                 \
                                                                     \
-  void wxLog##level(const wxChar *szFormat, ...)                    \
+  void wxDoLog##level(const wxChar *szFormat, ...)                  \
   {                                                                 \
     va_list argptr;                                                 \
     va_start(argptr, szFormat);                                     \
@@ -193,17 +194,17 @@ void wxLogVerbose(const wxChar *szFormat, ...)
     va_end(argptr);                                                 \
   }
 
-  void wxVLogTrace(const wxChar *mask, const wxChar *szFormat, va_list argptr)
+  void wxVLogTrace(const wxString& mask, const wxString& format, va_list argptr)
   {
     if ( wxLog::IsEnabled() && wxLog::IsAllowedTraceMask(mask) ) {
       wxString msg;
-      msg << _T("(") << mask << _T(") ") << wxString::FormatV(szFormat, argptr);
-          
+      msg << _T("(") << mask << _T(") ") << wxString::FormatV(format, argptr);
+
       wxLog::OnLog(wxLOG_Trace, msg, time(NULL));
     }
   }
 
-  void wxLogTrace(const wxChar *mask, const wxChar *szFormat, ...)
+  void wxDoLogTrace(const wxString& mask, const wxChar *szFormat, ...)
   {
     va_list argptr;
     va_start(argptr, szFormat);
@@ -211,17 +212,17 @@ void wxLogVerbose(const wxChar *szFormat, ...)
     va_end(argptr);
   }
 
-  void wxVLogTrace(wxTraceMask mask, const wxChar *szFormat, va_list argptr)
+  void wxVLogTrace(wxTraceMask mask, const wxString& format, va_list argptr)
   {
     // we check that all of mask bits are set in the current mask, so
     // that wxLogTrace(wxTraceRefCount | wxTraceOle) will only do something
     // if both bits are set.
     if ( wxLog::IsEnabled() && ((wxLog::GetTraceMask() & mask) == mask) ) {
-      wxLog::OnLog(wxLOG_Trace, wxString::FormatV(szFormat, argptr), time(NULL));
+      wxLog::OnLog(wxLOG_Trace, wxString::FormatV(format, argptr), time(NULL));
     }
   }
 
-  void wxLogTrace(wxTraceMask mask, const wxChar *szFormat, ...)
+  void wxDoLogTrace(wxTraceMask mask, const wxChar *szFormat, ...)
   {
     va_list argptr;
     va_start(argptr, szFormat);
@@ -245,12 +246,12 @@ static inline wxString wxLogSysErrorHelper(long err)
     return wxString::Format(_(" (error %ld: %s)"), err, wxSysErrorMsg(err));
 }
 
-void WXDLLEXPORT wxVLogSysError(const wxChar *szFormat, va_list argptr)
+void WXDLLEXPORT wxVLogSysError(const wxString& format, va_list argptr)
 {
-    wxVLogSysError(wxSysErrorCode(), szFormat, argptr);
+    wxVLogSysError(wxSysErrorCode(), format, argptr);
 }
 
-void WXDLLEXPORT wxLogSysError(const wxChar *szFormat, ...)
+void WXDLLEXPORT wxDoLogSysError(const wxChar *szFormat, ...)
 {
     va_list argptr;
     va_start(argptr, szFormat);
@@ -258,16 +259,16 @@ void WXDLLEXPORT wxLogSysError(const wxChar *szFormat, ...)
     va_end(argptr);
 }
 
-void WXDLLEXPORT wxVLogSysError(long err, const wxChar *fmt, va_list argptr)
+void WXDLLEXPORT wxVLogSysError(long err, const wxString& format, va_list argptr)
 {
     if ( wxLog::IsEnabled() ) {
         wxLog::OnLog(wxLOG_Error,
-                     wxString::FormatV(fmt, argptr) + wxLogSysErrorHelper(err),
+                     wxString::FormatV(format, argptr) + wxLogSysErrorHelper(err),
                      time(NULL));
     }
 }
 
-void WXDLLEXPORT wxLogSysError(long lErrCode, const wxChar *szFormat, ...)
+void WXDLLEXPORT wxDoLogSysError(long lErrCode, const wxChar *szFormat, ...)
 {
     va_list argptr;
     va_start(argptr, szFormat);
@@ -328,7 +329,7 @@ void wxLog::OnLog(wxLogLevel level, const wxChar *szString, time_t t)
             {
                 if ( GetRepetitionCounting() )
                 {
-                    pLogger->DoLogNumberOfRepeats();
+                    DoLogNumberOfRepeats();
                 }
                 ms_prevString = szString;
                 ms_prevLevel = level;
@@ -411,16 +412,21 @@ void wxLog::ClearTraceMasks()
 
 void wxLog::TimeStamp(wxString *str)
 {
+#if wxUSE_DATETIME
     if ( ms_timestamp )
     {
         wxChar buf[256];
         time_t timeNow;
         (void)time(&timeNow);
-        wxStrftime(buf, WXSIZEOF(buf), ms_timestamp, localtime(&timeNow));
+
+        struct tm tm;
+        wxStrftime(buf, WXSIZEOF(buf),
+                    ms_timestamp, wxLocaltime_r(&timeNow, &tm));
 
         str->Empty();
         *str << buf << wxT(": ");
     }
+#endif // wxUSE_DATETIME
 }
 
 void wxLog::DoLog(wxLogLevel level, const wxChar *szString, time_t t)
@@ -549,8 +555,8 @@ void wxLogStderr::DoLogString(const wxChar *szString, time_t WXUNUSED(t))
     TimeStamp(&str);
     str << szString;
 
-    fputs(str.mb_str(), m_fp);
-    fputc(_T('\n'), m_fp);
+    wxFputs(str, m_fp);
+    wxFputc(_T('\n'), m_fp);
     fflush(m_fp);
 
     // under GUI systems such as Windows or Mac, programs usually don't have