Uses Unicode strings. Now we've got a __TFILE__ macro, too (I think?)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2112 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -14,6 +14,13 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "wx/wxchar.h"
|
||||||
|
|
||||||
|
#ifndef __TFILE__
|
||||||
|
#define __XFILE__(x) _T(x)
|
||||||
|
#define __TFILE__ __XFILE__(__FILE__)
|
||||||
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
@name Debugging macros
|
@name Debugging macros
|
||||||
@@ -51,18 +58,18 @@
|
|||||||
@param szFile and nLine - file name and line number of the ASSERT
|
@param szFile and nLine - file name and line number of the ASSERT
|
||||||
szMsg - optional message explaining the reason
|
szMsg - optional message explaining the reason
|
||||||
*/
|
*/
|
||||||
void WXDLLEXPORT wxOnAssert(const char *szFile, int nLine, const char *szMsg = (const char *) NULL);
|
void WXDLLEXPORT wxOnAssert(const wxChar *szFile, int nLine, const wxChar *szMsg = (const wxChar *) NULL);
|
||||||
|
|
||||||
/// generic assert macro
|
/// generic assert macro
|
||||||
#define wxASSERT(cond) if ( !(cond) ) wxOnAssert(__FILE__, __LINE__)
|
#define wxASSERT(cond) if ( !(cond) ) wxOnAssert(__TFILE__, __LINE__)
|
||||||
|
|
||||||
#if 0 // defined(__BORLANDC__) && defined(__WIN16__)
|
#if 0 // defined(__BORLANDC__) && defined(__WIN16__)
|
||||||
// Too much text, so make wxASSERT_MSG the same as wxASSERT,
|
// Too much text, so make wxASSERT_MSG the same as wxASSERT,
|
||||||
// thus removing the text from the program.
|
// thus removing the text from the program.
|
||||||
#define wxASSERT_MSG(x, m) if ( !(x) ) wxOnAssert(__FILE__, __LINE__)
|
#define wxASSERT_MSG(x, m) if ( !(x) ) wxOnAssert(__TFILE__, __LINE__)
|
||||||
#else
|
#else
|
||||||
/// assert with additional message explaining it's cause
|
/// assert with additional message explaining it's cause
|
||||||
#define wxASSERT_MSG(x, m) if ( !(x) ) wxOnAssert(__FILE__, __LINE__, m)
|
#define wxASSERT_MSG(x, m) if ( !(x) ) wxOnAssert(__TFILE__, __LINE__, m)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@@ -115,4 +122,3 @@
|
|||||||
//@}
|
//@}
|
||||||
|
|
||||||
#endif // _WX_DEBUG_H_
|
#endif // _WX_DEBUG_H_
|
||||||
|
|
||||||
|
@@ -107,7 +107,7 @@ public:
|
|||||||
|
|
||||||
// static sink function - see DoLog() for function to overload in the
|
// static sink function - see DoLog() for function to overload in the
|
||||||
// derived classes
|
// derived classes
|
||||||
static void OnLog(wxLogLevel level, const char *szString, time_t t)
|
static void OnLog(wxLogLevel level, const wxChar *szString, time_t t)
|
||||||
{
|
{
|
||||||
if ( IsEnabled() ) {
|
if ( IsEnabled() ) {
|
||||||
wxLog *pLogger = GetActiveTarget();
|
wxLog *pLogger = GetActiveTarget();
|
||||||
@@ -154,7 +154,7 @@ public:
|
|||||||
// get trace mask
|
// get trace mask
|
||||||
static wxTraceMask GetTraceMask() { return ms_ulTraceMask; }
|
static wxTraceMask GetTraceMask() { return ms_ulTraceMask; }
|
||||||
// is this trace mask in the list?
|
// is this trace mask in the list?
|
||||||
static bool IsAllowedTraceMask(const char *mask)
|
static bool IsAllowedTraceMask(const wxChar *mask)
|
||||||
{ return ms_aTraceMasks.Index(mask) != wxNOT_FOUND; }
|
{ return ms_aTraceMasks.Index(mask) != wxNOT_FOUND; }
|
||||||
|
|
||||||
// make dtor virtual for all derived classes
|
// make dtor virtual for all derived classes
|
||||||
@@ -167,10 +167,10 @@ protected:
|
|||||||
// the logging functions that can be overriden
|
// the logging functions that can be overriden
|
||||||
// default DoLog() prepends the time stamp and a prefix corresponding
|
// default DoLog() prepends the time stamp and a prefix corresponding
|
||||||
// to the message to szString and then passes it to DoLogString()
|
// to the message to szString and then passes it to DoLogString()
|
||||||
virtual void DoLog(wxLogLevel level, const char *szString, time_t t);
|
virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t);
|
||||||
// default DoLogString does nothing but is not pure virtual because if
|
// default DoLogString does nothing but is not pure virtual because if
|
||||||
// you override DoLog() you might not need it at all
|
// you override DoLog() you might not need it at all
|
||||||
virtual void DoLogString(const char *szString, time_t t);
|
virtual void DoLogString(const wxChar *szString, time_t t);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// static variables
|
// static variables
|
||||||
@@ -197,7 +197,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// implement sink function
|
// implement sink function
|
||||||
virtual void DoLogString(const char *szString, time_t t);
|
virtual void DoLogString(const wxChar *szString, time_t t);
|
||||||
|
|
||||||
FILE *m_fp;
|
FILE *m_fp;
|
||||||
};
|
};
|
||||||
@@ -212,7 +212,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// implement sink function
|
// implement sink function
|
||||||
virtual void DoLogString(const char *szString, time_t t);
|
virtual void DoLogString(const wxChar *szString, time_t t);
|
||||||
|
|
||||||
// using ptr here to avoid including <iostream.h> from this file
|
// using ptr here to avoid including <iostream.h> from this file
|
||||||
ostream *m_ostr;
|
ostream *m_ostr;
|
||||||
@@ -245,7 +245,7 @@ public:
|
|||||||
virtual void Flush();
|
virtual void Flush();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void DoLog(wxLogLevel level, const char *szString, time_t t);
|
virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t);
|
||||||
|
|
||||||
// empty everything
|
// empty everything
|
||||||
void Clear();
|
void Clear();
|
||||||
@@ -266,7 +266,7 @@ class WXDLLEXPORT wxLogWindow : public wxLog
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
|
wxLogWindow(wxFrame *pParent, // the parent frame (can be NULL)
|
||||||
const char *szTitle, // the title of the frame
|
const wxChar *szTitle, // the title of the frame
|
||||||
bool bShow = TRUE, // show window immediately?
|
bool bShow = TRUE, // show window immediately?
|
||||||
bool bPassToOld = TRUE); // pass log messages to the old target?
|
bool bPassToOld = TRUE); // pass log messages to the old target?
|
||||||
~wxLogWindow();
|
~wxLogWindow();
|
||||||
@@ -300,8 +300,8 @@ public:
|
|||||||
virtual void OnFrameDelete(wxFrame *frame);
|
virtual void OnFrameDelete(wxFrame *frame);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void DoLog(wxLogLevel level, const char *szString, time_t t);
|
virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t);
|
||||||
virtual void DoLogString(const char *szString, time_t t);
|
virtual void DoLogString(const wxChar *szString, time_t t);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_bPassMessages; // pass messages to m_pOldLog?
|
bool m_bPassMessages; // pass messages to m_pOldLog?
|
||||||
@@ -351,9 +351,9 @@ private:
|
|||||||
// -------------------
|
// -------------------
|
||||||
|
|
||||||
#define DECLARE_LOG_FUNCTION(level) \
|
#define DECLARE_LOG_FUNCTION(level) \
|
||||||
extern void WXDLLEXPORT wxLog##level(const char *szFormat, ...)
|
extern void WXDLLEXPORT wxLog##level(const wxChar *szFormat, ...)
|
||||||
#define DECLARE_LOG_FUNCTION2(level, arg1) \
|
#define DECLARE_LOG_FUNCTION2(level, arg1) \
|
||||||
extern void WXDLLEXPORT wxLog##level(arg1, const char *szFormat, ...)
|
extern void WXDLLEXPORT wxLog##level(arg1, const wxChar *szFormat, ...)
|
||||||
|
|
||||||
// a generic function for all levels (level is passes as parameter)
|
// a generic function for all levels (level is passes as parameter)
|
||||||
DECLARE_LOG_FUNCTION2(Generic, wxLogLevel level);
|
DECLARE_LOG_FUNCTION2(Generic, wxLogLevel level);
|
||||||
@@ -399,10 +399,10 @@ extern void WXDLLEXPORT wxLog##level(arg1, const char *szFormat, ...)
|
|||||||
DECLARE_LOG_FUNCTION2(Trace, wxTraceMask mask);
|
DECLARE_LOG_FUNCTION2(Trace, wxTraceMask mask);
|
||||||
#else //!debug
|
#else //!debug
|
||||||
// these functions do nothing in release builds
|
// these functions do nothing in release builds
|
||||||
inline void wxLogDebug(const char *, ...) { }
|
inline void wxLogDebug(const wxChar *, ...) { }
|
||||||
inline void wxLogTrace(const char *, ...) { }
|
inline void wxLogTrace(const wxChar *, ...) { }
|
||||||
inline void wxLogTrace(wxTraceMask, const char *, ...) { }
|
inline void wxLogTrace(wxTraceMask, const wxChar *, ...) { }
|
||||||
inline void wxLogTrace(const char *, const char *, ...) { }
|
inline void wxLogTrace(const wxChar *, const wxChar *, ...) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -419,21 +419,26 @@ extern void WXDLLEXPORT wxLog##level(arg1, const char *szFormat, ...)
|
|||||||
// return the last system error code
|
// return the last system error code
|
||||||
WXDLLEXPORT unsigned long wxSysErrorCode();
|
WXDLLEXPORT unsigned long wxSysErrorCode();
|
||||||
// return the error message for given (or last if 0) error code
|
// return the error message for given (or last if 0) error code
|
||||||
WXDLLEXPORT const char* wxSysErrorMsg(unsigned long nErrCode = 0);
|
WXDLLEXPORT const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0);
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// debug only logging functions: use them with API name and error code
|
// debug only logging functions: use them with API name and error code
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef __TFILE__
|
||||||
|
#define __XFILE__(x) _T(x)
|
||||||
|
#define __TFILE__ __XFILE__(__FILE__)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
#define wxLogApiError(api, rc) \
|
#define wxLogApiError(api, rc) \
|
||||||
wxLogDebug("At %s(%d) '%s' failed with error %lx (%s).", \
|
wxLogDebug(_T("At %s(%d) '%s' failed with error %lx (%s)."), \
|
||||||
__FILE__, __LINE__, api, \
|
__TFILE__, __LINE__, api, \
|
||||||
rc, wxSysErrorMsg(rc))
|
rc, wxSysErrorMsg(rc))
|
||||||
#define wxLogLastError(api) wxLogApiError(api, wxSysErrorCode())
|
#define wxLogLastError(api) wxLogApiError(api, wxSysErrorCode())
|
||||||
#else //!debug
|
#else //!debug
|
||||||
inline void wxLogApiError(const char *, long) { }
|
inline void wxLogApiError(const wxChar *, long) { }
|
||||||
inline void wxLogLastError(const char *) { }
|
inline void wxLogLastError(const wxChar *) { }
|
||||||
#endif //debug/!debug
|
#endif //debug/!debug
|
||||||
|
|
||||||
#endif // _WX_LOG_H_
|
#endif // _WX_LOG_H_
|
||||||
|
Reference in New Issue
Block a user