-// 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.
-// ----------------------------------------------------------------------------
-
-// log functions can't allocate memory (LogError("out of memory...") should
-// work!), so we use a static buffer for all log messages
-#define LOG_BUFFER_SIZE (4096)
-
-// static buffer for error messages (@@@ MT-unsafe)
-static char s_szBuf[LOG_BUFFER_SIZE];
-
-// generic log function
-void wxLogGeneric(wxLog::Level level, wxTString strFormat, ...)
-{
- if ( wxLog::GetActiveTarget() != NULL ) {
- va_list argptr;
- va_start(argptr, strFormat);
- vsprintf(s_szBuf, strFormat, argptr);
- va_end(argptr);
-
- wxLog::OnLog(level, s_szBuf);
- }
-}
-
-#define IMPLEMENT_LOG_FUNCTION(level) \
- void wxLog##level(wxTString strFormat, ...) \
- { \
- if ( wxLog::GetActiveTarget() != NULL ) { \
- va_list argptr; \
- va_start(argptr, strFormat); \
- vsprintf(s_szBuf, strFormat, argptr); \
- va_end(argptr); \
- \
- wxLog::OnLog(wxLog::level, s_szBuf); \
- } \
- }
-
-IMPLEMENT_LOG_FUNCTION(FatalError)
-IMPLEMENT_LOG_FUNCTION(Error)
-IMPLEMENT_LOG_FUNCTION(Warning)
-IMPLEMENT_LOG_FUNCTION(Message)
-IMPLEMENT_LOG_FUNCTION(Info)
-IMPLEMENT_LOG_FUNCTION(Status)
-
-// debug functions don't use wxTString
-#undef IMPLEMENT_LOG_FUNCTION
-#define IMPLEMENT_LOG_FUNCTION(level) \
- void wxLog##level(const char *szFormat, ...) \
- { \
- if ( wxLog::GetActiveTarget() != NULL ) { \
- va_list argptr; \
- va_start(argptr, szFormat); \
- vsprintf(s_szBuf, szFormat, argptr); \
- va_end(argptr); \
- \
- wxLog::OnLog(wxLog::level, s_szBuf); \
- } \
- }
-
-IMPLEMENT_LOG_FUNCTION(Debug)
-IMPLEMENT_LOG_FUNCTION(Trace)
-
-void wxLogVerbose(wxTString strFormat, ...)
-{
- if ( wxLog::GetVerbose() && wxLog::GetActiveTarget() != NULL ) {
- va_list argptr;
- va_start(argptr, strFormat);
- vsprintf(s_szBuf, strFormat, argptr);
- va_end(argptr);
-
- wxLog::OnLog(wxLog::Info, s_szBuf);
- }
-}
-
-void wxLogSysError(wxTString str, ...)
-{
- if ( wxLog::GetActiveTarget() != NULL ) {
- va_list argptr;
- va_start(argptr, str);
- vsprintf(s_szBuf, str, argptr);
- va_end(argptr);
-
- char szErrMsg[LOG_BUFFER_SIZE / 2];
- sprintf(szErrMsg, _(" (error %ld: %s)"), wxSysErrorCode(), wxSysErrorMsg());
- strncat(s_szBuf, szErrMsg, WXSIZEOF(s_szBuf) - strlen(s_szBuf));
-
- wxLog::OnLog(wxLog::Error, s_szBuf);
- }
-}
-
-void WXDLLEXPORT wxLogSysError(long lErrCode, wxTString strFormat, ...)
-{
- if ( wxLog::GetActiveTarget() != NULL ) {
- va_list argptr;
- va_start(argptr, strFormat);
- vsprintf(s_szBuf, strFormat, argptr);
- va_end(argptr);
-
- char szErrMsg[LOG_BUFFER_SIZE / 2];
- sprintf(szErrMsg, _(" (error %ld: %s)"), lErrCode, wxSysErrorMsg(lErrCode));
- strncat(s_szBuf, szErrMsg, WXSIZEOF(s_szBuf) - strlen(s_szBuf));
-
- wxLog::OnLog(wxLog::Error, s_szBuf);
- }