+// static buffer for error messages
+static wxChar s_szBufStatic[LOG_BUFFER_SIZE];
+
+static wxChar *s_szBuf = s_szBufStatic;
+static size_t s_szBufSize = WXSIZEOF( s_szBufStatic );
+
+#if wxUSE_THREADS
+
+// the critical section protecting the static buffer
+static wxCriticalSection gs_csLogBuf;
+
+#endif // wxUSE_THREADS
+
+// ----------------------------------------------------------------------------
+// implementation of Log functions
+//
+// NB: unfortunately we need all these distinct functions, we can't make them
+// macros and not all compilers inline vararg functions.
+// ----------------------------------------------------------------------------
+
+// wrapper for wxVsnprintf(s_szBuf) which always NULL-terminates it
+static inline void PrintfInLogBuf(const wxChar *szFormat, va_list argptr)
+{
+ if ( wxVsnprintf(s_szBuf, s_szBufSize, szFormat, argptr) < 0 )
+ {
+ // must NUL-terminate it manually
+ s_szBuf[s_szBufSize - 1] = _T('\0');
+ }
+ //else: NUL-terminated by vsnprintf()
+}