// ctor
wxLog();
+ // Internal buffer.
+ // Allow replacement of the fixed size static buffer with
+ // a user allocated one. Pass in NULL to restore the
+ // built in static buffer.
+ static wxChar *SetLogBuffer( wxChar *buf, size_t size = 0 );
+
// these functions allow to completely disable all log messages
// is logging disabled now?
static bool IsEnabled() { return ms_doLog; }
// log everything to a "FILE *", stderr by default
class WXDLLEXPORT wxLogStderr : public wxLog
{
+ DECLARE_NO_COPY_CLASS(wxLogStderr)
+
public:
// redirect log output to a FILE
wxLogStderr(FILE *fp = (FILE *) NULL);
class WXDLLEXPORT wxLogNull
{
public:
- wxLogNull() { m_flagOld = wxLog::EnableLogging(FALSE); }
- ~wxLogNull() { (void)wxLog::EnableLogging(m_flagOld); }
+ wxLogNull() : m_flagOld(wxLog::EnableLogging(FALSE)) { }
+ ~wxLogNull() { (void)wxLog::EnableLogging(m_flagOld); }
private:
bool m_flagOld; // the previous value of the wxLog::ms_doLog
{
public:
wxLogChain(wxLog *logger);
- virtual ~wxLogChain() { delete m_logOld; }
+ virtual ~wxLogChain();
// change the new log target
void SetLog(wxLog *logger);
// return the last system error code
WXDLLEXPORT unsigned long wxSysErrorCode();
+
// return the error message for given (or last if 0) error code
WXDLLEXPORT const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0);
+// ----------------------------------------------------------------------------
// define wxLog<level>
-// -------------------
+// ----------------------------------------------------------------------------
#define DECLARE_LOG_FUNCTION(level) \
-extern void WXDLLEXPORT wxLog##level(const wxChar *szFormat, \
+extern void WXDLLEXPORT wxVLog##level(const wxChar *szFormat, \
va_list argptr); \
-extern void WXDLLEXPORT wxLog##level(const wxChar *szFormat, ...)
+extern void WXDLLEXPORT wxLog##level(const wxChar *szFormat, \
+ ...) ATTRIBUTE_PRINTF_1
#define DECLARE_LOG_FUNCTION2(level, arg1) \
-extern void WXDLLEXPORT wxLog##level(arg1, const wxChar *szFormat, \
+extern void WXDLLEXPORT wxVLog##level(arg1, const wxChar *szFormat, \
va_list argptr); \
-extern void WXDLLEXPORT wxLog##level(arg1, const wxChar *szFormat, ...)
+extern void WXDLLEXPORT wxLog##level(arg1, const wxChar *szFormat, \
+ ...) ATTRIBUTE_PRINTF_2
#else // !wxUSE_LOG
// log functions do nothing at all
#define DECLARE_LOG_FUNCTION(level) \
-inline void WXDLLEXPORT wxLog##level(const wxChar *szFormat, \
+inline void WXDLLEXPORT wxVLog##level(const wxChar *szFormat, \
va_list argptr) {} \
inline void WXDLLEXPORT wxLog##level(const wxChar *szFormat, ...) {}
#define DECLARE_LOG_FUNCTION2(level, arg1) \
-inline void WXDLLEXPORT wxLog##level(arg1, const wxChar *szFormat, \
+inline void WXDLLEXPORT wxVLog##level(arg1, const wxChar *szFormat, \
va_list argptr) {} \
inline void WXDLLEXPORT wxLog##level(arg1, const wxChar *szFormat, ...) {}
DECLARE_LOG_FUNCTION2(Trace, wxTraceMask mask);
#else //!debug
// these functions do nothing in release builds
- inline void wxLogDebug(const wxChar *, va_list) { }
+ inline void wxVLogDebug(const wxChar *, va_list) { }
inline void wxLogDebug(const wxChar *, ...) { }
- inline void wxLogTrace(const wxChar *, va_list) { }
+ inline void wxVLogTrace(const wxChar *, va_list) { }
inline void wxLogTrace(const wxChar *, ...) { }
- inline void wxLogTrace(wxTraceMask, const wxChar *, va_list) { }
+ inline void wxVLogTrace(wxTraceMask, const wxChar *, va_list) { }
inline void wxLogTrace(wxTraceMask, const wxChar *, ...) { }
- inline void wxLogTrace(const wxChar *, const wxChar *, va_list) { }
+ inline void wxVLogTrace(const wxChar *, const wxChar *, va_list) { }
inline void wxLogTrace(const wxChar *, const wxChar *, ...) { }
#endif // debug/!debug
+// wxLogFatalError helper: show the (fatal) error to the user in a safe way,
+// i.e. without using wxMessageBox() for example because it could crash
+void WXDLLEXPORT wxSafeShowMessage(const wxString& title, const wxString& text);
+
// ----------------------------------------------------------------------------
// debug only logging functions: use them with API name and error code
// ----------------------------------------------------------------------------
#ifdef __VISUALC__
#define wxLogApiError(api, rc) \
wxLogDebug(wxT("%s(%d): '%s' failed with error 0x%08lx (%s)."), \
- __TFILE__, __LINE__, api, \
- rc, wxSysErrorMsg(rc))
+ __TFILE__, __LINE__, api, \
+ (long)rc, wxSysErrorMsg(rc))
#else // !VC++
#define wxLogApiError(api, rc) \
wxLogDebug(wxT("In file %s at line %d: '%s' failed with " \
- "error 0x%08lx (%s)."), \
- __TFILE__, __LINE__, api, \
- rc, wxSysErrorMsg(rc))
+ "error 0x%08lx (%s)."), \
+ __TFILE__, __LINE__, api, \
+ (long)rc, wxSysErrorMsg(rc))
#endif // VC++/!VC++
#define wxLogLastError(api) wxLogApiError(api, wxSysErrorCode())
#endif //debug/!debug
#endif // _WX_LOG_H_
+