+ // ctor takes the basic information about the log record
+ wxLogger(wxLogLevel level,
+ const char *filename,
+ int line,
+ const char *func,
+ const char *component)
+ : m_level(level),
+ m_info(filename, line, func, component)
+ {
+ }
+
+ // store extra data in our log record and return this object itself (so
+ // that further calls to its functions could be chained)
+ template <typename T>
+ wxLogger& Store(const wxString& key, T val)
+ {
+ m_info.StoreValue(key, val);
+ return *this;
+ }
+
+ // hack for "overloaded" wxLogXXX() functions: calling this method
+ // indicates that we may have an extra first argument preceding the format
+ // string and that if we do have it, we should store it in m_info using the
+ // given key (while by default 0 value will be used)
+ wxLogger& MaybeStore(const wxString& key, wxUIntPtr value = 0)
+ {
+ wxASSERT_MSG( m_optKey.empty(), "can only have one optional value" );
+ m_optKey = key;
+
+ m_info.StoreValue(key, value);
+ return *this;
+ }
+
+
+ // non-vararg function used by wxVLogXXX():
+
+ // log the message at the level specified in the ctor if this log message
+ // is enabled
+ void LogV(const wxString& format, va_list argptr)
+ {
+ // remember that fatal errors can't be disabled
+ if ( m_level == wxLOG_FatalError ||
+ wxLog::IsLevelEnabled(m_level, m_info.component) )
+ DoCallOnLog(format, argptr);
+ }
+
+ // overloads used by functions with optional leading arguments (whose
+ // values are stored in the key passed to MaybeStore())
+ void LogV(long num, const wxString& format, va_list argptr)
+ {
+ Store(m_optKey, num);
+
+ LogV(format, argptr);
+ }
+
+ void LogV(void *ptr, const wxString& format, va_list argptr)
+ {
+ Store(m_optKey, wxPtrToUInt(ptr));
+
+ LogV(format, argptr);
+ }
+
+ void LogVTrace(const wxString& mask, const wxString& format, va_list argptr)
+ {
+ if ( !wxLog::IsAllowedTraceMask(mask) )
+ return;
+
+ Store(wxLOG_KEY_TRACE_MASK, mask);
+
+ LogV(format, argptr);
+ }
+
+
+ // vararg functions used by wxLogXXX():
+
+ // will log the message at the level specified in the ctor
+ //
+ // notice that this function supposes that the caller already checked that
+ // the level was enabled and does no checks itself
+ WX_DEFINE_VARARG_FUNC_VOID
+ (
+ Log,
+ 1, (const wxFormatString&),
+ DoLog, DoLogUtf8
+ )
+
+ // same as Log() but with an extra numeric or pointer parameters: this is
+ // used to pass an optional value by storing it in m_info under the name
+ // passed to MaybeStore() and is required to support "overloaded" versions
+ // of wxLogStatus() and wxLogSysError()
+ WX_DEFINE_VARARG_FUNC_VOID
+ (
+ Log,
+ 2, (long, const wxFormatString&),
+ DoLogWithNum, DoLogWithNumUtf8
+ )
+
+ // unfortunately we can't use "void *" here as we get overload ambiguities
+ // with Log(wxFormatString, ...) when the first argument is a "char *" or
+ // "wchar_t *" then -- so we only allow passing wxObject here, which is
+ // ugly but fine in practice as this overload is only used by wxLogStatus()
+ // whose first argument is a wxFrame
+ WX_DEFINE_VARARG_FUNC_VOID
+ (
+ Log,
+ 2, (wxObject *, const wxFormatString&),
+ DoLogWithPtr, DoLogWithPtrUtf8
+ )
+
+ // log the message at the level specified as its first argument
+ //
+ // as the macros don't have access to the level argument in this case, this
+ // function does check that the level is enabled itself
+ WX_DEFINE_VARARG_FUNC_VOID
+ (
+ LogAtLevel,
+ 2, (wxLogLevel, const wxFormatString&),
+ DoLogAtLevel, DoLogAtLevelUtf8
+ )
+
+ // special versions for wxLogTrace() which is passed either string or
+ // integer mask as first argument determining whether the message should be
+ // logged or not
+ WX_DEFINE_VARARG_FUNC_VOID
+ (
+ LogTrace,
+ 2, (const wxString&, const wxFormatString&),
+ DoLogTrace, DoLogTraceUtf8
+ )
+
+#if WXWIN_COMPATIBILITY_2_8
+ WX_DEFINE_VARARG_FUNC_VOID
+ (
+ LogTrace,
+ 2, (wxTraceMask, const wxFormatString&),
+ DoLogTraceMask, DoLogTraceMaskUtf8
+ )
+#endif // WXWIN_COMPATIBILITY_2_8
+
+#ifdef __WATCOMC__
+ // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
+ WX_VARARG_WATCOM_WORKAROUND(void, Log,
+ 1, (const wxString&),
+ (wxFormatString(f1)))
+ WX_VARARG_WATCOM_WORKAROUND(void, Log,
+ 1, (const wxCStrData&),
+ (wxFormatString(f1)))
+ WX_VARARG_WATCOM_WORKAROUND(void, Log,
+ 1, (const char*),
+ (wxFormatString(f1)))
+ WX_VARARG_WATCOM_WORKAROUND(void, Log,
+ 1, (const wchar_t*),
+ (wxFormatString(f1)))
+
+ WX_VARARG_WATCOM_WORKAROUND(void, Log,
+ 2, (long, const wxString&),
+ (f1, wxFormatString(f2)))
+ WX_VARARG_WATCOM_WORKAROUND(void, Log,
+ 2, (long, const wxCStrData&),
+ (f1, wxFormatString(f2)))
+ WX_VARARG_WATCOM_WORKAROUND(void, Log,
+ 2, (long, const char *),
+ (f1, wxFormatString(f2)))
+ WX_VARARG_WATCOM_WORKAROUND(void, Log,
+ 2, (long, const wchar_t *),
+ (f1, wxFormatString(f2)))
+
+ WX_VARARG_WATCOM_WORKAROUND(void, Log,
+ 2, (wxObject *, const wxString&),
+ (f1, wxFormatString(f2)))
+ WX_VARARG_WATCOM_WORKAROUND(void, Log,
+ 2, (wxObject *, const wxCStrData&),
+ (f1, wxFormatString(f2)))
+ WX_VARARG_WATCOM_WORKAROUND(void, Log,
+ 2, (wxObject *, const char *),
+ (f1, wxFormatString(f2)))
+ WX_VARARG_WATCOM_WORKAROUND(void, Log,
+ 2, (wxObject *, const wchar_t *),
+ (f1, wxFormatString(f2)))
+
+ WX_VARARG_WATCOM_WORKAROUND(void, LogAtLevel,
+ 2, (wxLogLevel, const wxString&),
+ (f1, wxFormatString(f2)))
+ WX_VARARG_WATCOM_WORKAROUND(void, LogAtLevel,
+ 2, (wxLogLevel, const wxCStrData&),
+ (f1, wxFormatString(f2)))
+ WX_VARARG_WATCOM_WORKAROUND(void, LogAtLevel,
+ 2, (wxLogLevel, const char *),
+ (f1, wxFormatString(f2)))
+ WX_VARARG_WATCOM_WORKAROUND(void, LogAtLevel,
+ 2, (wxLogLevel, const wchar_t *),
+ (f1, wxFormatString(f2)))
+
+ WX_VARARG_WATCOM_WORKAROUND(void, LogTrace,
+ 2, (const wxString&, const wxString&),
+ (f1, wxFormatString(f2)))
+ WX_VARARG_WATCOM_WORKAROUND(void, LogTrace,
+ 2, (const wxString&, const wxCStrData&),
+ (f1, wxFormatString(f2)))
+ WX_VARARG_WATCOM_WORKAROUND(void, LogTrace,
+ 2, (const wxString&, const char *),
+ (f1, wxFormatString(f2)))
+ WX_VARARG_WATCOM_WORKAROUND(void, LogTrace,
+ 2, (const wxString&, const wchar_t *),
+ (f1, wxFormatString(f2)))
+
+#if WXWIN_COMPATIBILITY_2_8
+ WX_VARARG_WATCOM_WORKAROUND(void, LogTrace,
+ 2, (wxTraceMask, wxTraceMask),
+ (f1, wxFormatString(f2)))
+ WX_VARARG_WATCOM_WORKAROUND(void, LogTrace,
+ 2, (wxTraceMask, const wxCStrData&),
+ (f1, wxFormatString(f2)))
+ WX_VARARG_WATCOM_WORKAROUND(void, LogTrace,
+ 2, (wxTraceMask, const char *),
+ (f1, wxFormatString(f2)))
+ WX_VARARG_WATCOM_WORKAROUND(void, LogTrace,
+ 2, (wxTraceMask, const wchar_t *),
+ (f1, wxFormatString(f2)))
+#endif // WXWIN_COMPATIBILITY_2_8
+#endif // __WATCOMC__