X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8b30a4e4d68084d5bd2e775685d09e72055f4ccf..698052d5f125427b4ac62e1968a090f697aea8ae:/include/wx/log.h?ds=inline diff --git a/include/wx/log.h b/include/wx/log.h index 28272c9b9c..44266ab80e 100644 --- a/include/wx/log.h +++ b/include/wx/log.h @@ -240,6 +240,8 @@ private: // 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); @@ -293,8 +295,8 @@ protected: 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 @@ -474,20 +476,24 @@ private: // 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 -// ------------------- +// ---------------------------------------------------------------------------- #define DECLARE_LOG_FUNCTION(level) \ 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 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 @@ -557,6 +563,10 @@ DECLARE_LOG_FUNCTION2(SysError, long lErrCode); 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 // ---------------------------------------------------------------------------- @@ -567,14 +577,14 @@ DECLARE_LOG_FUNCTION2(SysError, long lErrCode); #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()) @@ -586,4 +596,3 @@ DECLARE_LOG_FUNCTION2(SysError, long lErrCode); #endif // _WX_LOG_H_ -// vi:sts=4:sw=4:et