#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);
}
#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); \
// 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);
#endif
}
-void wxLogFatalError(const wxChar *szFormat, ...)
+void wxDoLogFatalError(const wxChar *szFormat, ...)
{
va_list argptr;
va_start(argptr, 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);
} \
} \
\
- void wxLog##level(const wxChar *szFormat, ...) \
+ void wxDoLog##level(const wxChar *szFormat, ...) \
{ \
va_list argptr; \
va_start(argptr, 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);
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);
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);
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);
{
if ( GetRepetitionCounting() )
{
- pLogger->DoLogNumberOfRepeats();
+ DoLogNumberOfRepeats();
}
ms_prevString = szString;
ms_prevLevel = level;
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)
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