\membersection{::wxVsnprintf}\label{wxvsnprintf}
-\func{int}{wxVsnprintf}{\param{wxChar *}{buf}, \param{size\_t }{len}, \param{const wxChar *}{format}, \param{va\_list }{argptr}}
+\func{int}{wxVsnprintf}{\param{wxChar *}{buf}, \param{size\_t }{len}, \param{const wxChar *}{format}, \param{va\_list }{argPtr}}
The same as \helpref{wxSnprintf}{wxsnprintf} but takes a {\tt va\_list}
argument instead of arbitrary number of parameters.
\membersection{::wxLogError}\label{wxlogerror}
\func{void}{wxLogError}{\param{const char*}{ formatString}, \param{...}{}}
+\func{void}{wxLogError}{\param{const char*}{ formatString}, \param{va_list}{argPtr}}
-The function to use for error messages, i.e. the messages that must be shown
+The functions to use for error messages, i.e. the messages that must be shown
to the user. The default processing is to pop up a message box to inform the
user about it.
\membersection{::wxLogFatalError}\label{wxlogfatalerror}
\func{void}{wxLogFatalError}{\param{const char*}{ formatString}, \param{...}{}}
+\func{void}{wxLogFatalError}{\param{const char*}{ formatString}, \param{va_list}{argPtr}}
Like \helpref{wxLogError}{wxlogerror}, but also
terminates the program with the exit code 3. Using {\it abort()} standard
\membersection{::wxLogWarning}\label{wxlogwarning}
\func{void}{wxLogWarning}{\param{const char*}{ formatString}, \param{...}{}}
+\func{void}{wxLogWarning}{\param{const char*}{ formatString}, \param{va_list}{argPtr}}
For warnings - they are also normally shown to the user, but don't interrupt
the program work.
\membersection{::wxLogMessage}\label{wxlogmessage}
\func{void}{wxLogMessage}{\param{const char*}{ formatString}, \param{...}{}}
+\func{void}{wxLogMessage}{\param{const char*}{ formatString}, \param{va_list}{argPtr}}
-for all normal, informational messages. They also appear in a message box by
+For all normal, informational messages. They also appear in a message box by
default (but it can be changed). Notice that the standard behaviour is to not
show informational messages if there are any errors later - the logic being
that the later error messages make the informational messages preceding them
\membersection{::wxLogVerbose}\label{wxlogverbose}
\func{void}{wxLogVerbose}{\param{const char*}{ formatString}, \param{...}{}}
+\func{void}{wxLogVerbose}{\param{const char*}{ formatString}, \param{va_list}{argPtr}}
For verbose output. Normally, it is suppressed, but
might be activated if the user wishes to know more details about the program
\membersection{::wxLogStatus}\label{wxlogstatus}
\func{void}{wxLogStatus}{\param{wxFrame *}{frame}, \param{const char*}{ formatString}, \param{...}{}}
+\func{void}{wxLogStatus}{\param{wxFrame *}{frame}, \param{const char*}{ formatString}, \param{va_list}{argPtr}}
\func{void}{wxLogStatus}{\param{const char*}{ formatString}, \param{...}{}}
+\func{void}{wxLogStatus}{\param{const char*}{ formatString}, \param{va_list}{argPtr}}
-Messages logged by this function will appear in the statusbar of the {\it
+Messages logged by these functions will appear in the statusbar of the {\it
frame} or of the top level application window by default (i.e. when using
-the second version of the function).
+the second version of the functions).
If the target frame doesn't have a statusbar, the message will be lost.
\membersection{::wxLogSysError}\label{wxlogsyserror}
\func{void}{wxLogSysError}{\param{const char*}{ formatString}, \param{...}{}}
+\func{void}{wxLogSysError}{\param{const char*}{ formatString}, \param{va_list}{argPtr}}
Mostly used by wxWindows itself, but might be handy for logging errors after
system call (API function) failure. It logs the specified message text as well
\membersection{::wxLogDebug}\label{wxlogdebug}
\func{void}{wxLogDebug}{\param{const char*}{ formatString}, \param{...}{}}
+\func{void}{wxLogDebug}{\param{const char*}{ formatString}, \param{va_list}{argPtr}}
-The right function for debug output. It only does anything at all in the debug
-mode (when the preprocessor symbol \_\_WXDEBUG\_\_ is defined) and expands to
+The right functions for debug output. They only do something in debug
+mode (when the preprocessor symbol \_\_WXDEBUG\_\_ is defined) and expand to
nothing in release mode (otherwise).
\membersection{::wxLogTrace}\label{wxlogtrace}
\func{void}{wxLogTrace}{\param{const char*}{ formatString}, \param{...}{}}
+\func{void}{wxLogTrace}{\param{const char*}{ formatString}, \param{va_list}{argPtr}}
\func{void}{wxLogTrace}{\param{const char *}{mask}, \param{const char *}{formatString}, \param{...}{}}
+\func{void}{wxLogTrace}{\param{const char *}{mask}, \param{const char *}{formatString}, \param{va_list}{argPtr}}
\func{void}{wxLogTrace}{\param{wxTraceMask}{ mask}, \param{const char *}{formatString}, \param{...}{}}
+\func{void}{wxLogTrace}{\param{wxTraceMask}{ mask}, \param{const char *}{formatString}, \param{va_list}{argPtr}}
As {\bf wxLogDebug}, trace functions only do something in debug build and
expand to nothing in the release one. The reason for making
First of all, no knowledge of {\it wxLog} classes is needed to use them. For
this, you should only know about {\it wxLogXXX()} functions. All of them have
-the same syntax as {\it printf()}, i.e. they take the format string as the
-first argument and a variable number of arguments. Here are all of them:
+the same syntax as {\it printf()} or {\it vprintf()} , i.e. they take the
+format string as the first argument and respectively a variable number of
+arguments or a variable argument list pointer. Here are all of them:
\begin{itemize}\itemsep=0pt
\item{\bf wxLogFatalError} which is like {\it wxLogError}, but also
\item{\bf wxLogSysError} is mostly used by wxWindows itself, but might be
handy for logging errors after system call (API function) failure. It logs the
specified message text as well as the last system error
-code ({\it errno} or {\it ::GetLastError()} depending on the platform) and the corresponding error
-message. The second form of this function takes the error code explicitly as the
-first argument.
+code ({\it errno} or {\it ::GetLastError()} depending on the platform) and
+the corresponding error message. The second form of this function takes the
+error code explicitly as the first argument.
\item{\bf wxLogDebug} is {\bf the} right function for debug output. It only
does anything at all in the debug mode (when the preprocessor symbol
\_\_WXDEBUG\_\_ is defined) and expands to nothing in release mode (otherwise).
classes are. Some of advantages in using wxWindows log functions are:
\begin{itemize}\itemsep=0pt
-\item{\bf Portability} It is a common practice to use {\it printf()} statements or
-cout/cerr C++ streams for writing out some (debug or otherwise) information.
+\item{\bf Portability} It is a common practice to use {\it printf()}
+statements or cout/cerr C++ streams for writing out some (debug or otherwise)
+information.
Although it works just fine under Unix, these messages go strictly nowhere
under Windows where the stdout of GUI programs is not assigned to anything.
Thus, you might view {\it wxLogMessage()} as a simple substitute for {\it
// -------------------
#define DECLARE_LOG_FUNCTION(level) \
+extern void WXDLLEXPORT wxLog##level(const wxChar *szFormat, \
+ va_list argptr); \
extern void WXDLLEXPORT wxLog##level(const wxChar *szFormat, ...)
#define DECLARE_LOG_FUNCTION2(level, arg1) \
+extern void WXDLLEXPORT wxLog##level(arg1, const wxChar *szFormat, \
+ va_list argptr); \
extern void WXDLLEXPORT wxLog##level(arg1, const wxChar *szFormat, ...)
#else // !wxUSE_LOG
// log functions do nothing at all
#define DECLARE_LOG_FUNCTION(level) \
+inline void WXDLLEXPORT wxLog##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, \
+ va_list argptr) {} \
inline void WXDLLEXPORT wxLog##level(arg1, const wxChar *szFormat, ...) {}
#endif // wxUSE_LOG/!wxUSE_LOG
#ifdef __WXDEBUG__
DECLARE_LOG_FUNCTION(Debug);
- // first king of LogTrace is uncoditional: it doesn't check the level,
+ // first kind of LogTrace is unconditional: it doesn't check the level,
DECLARE_LOG_FUNCTION(Trace);
// this second version will only log the message if the mask had been
DECLARE_LOG_FUNCTION2(Trace, wxTraceMask mask);
#else //!debug
// these functions do nothing in release builds
+ inline void wxLogDebug(const wxChar *, va_list) { }
inline void wxLogDebug(const wxChar *, ...) { }
+ inline void wxLogTrace(const wxChar *, va_list) { }
inline void wxLogTrace(const wxChar *, ...) { }
+ inline void wxLogTrace(wxTraceMask, const wxChar *, va_list) { }
inline void wxLogTrace(wxTraceMask, const wxChar *, ...) { }
+ inline void wxLogTrace(const wxChar *, const wxChar *, va_list) { }
inline void wxLogTrace(const wxChar *, const wxChar *, ...) { }
#endif // debug/!debug
// ----------------------------------------------------------------------------
// generic log function
-void wxLogGeneric(wxLogLevel level, const wxChar *szFormat, ...)
+void wxLogGeneric(wxLogLevel level, const wxChar *szFormat, va_list argptr)
{
if ( IsLoggingEnabled() ) {
wxCRIT_SECT_LOCKER(locker, gs_csLogBuf);
- va_list argptr;
- va_start(argptr, szFormat);
wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr);
- va_end(argptr);
wxLog::OnLog(level, s_szBuf, time(NULL));
}
}
+void wxLogGeneric(wxLogLevel level, const wxChar *szFormat, ...)
+{
+ va_list argptr;
+ va_start(argptr, szFormat);
+ wxLogGeneric(level, szFormat, argptr);
+ va_end(argptr);
+}
+
#define IMPLEMENT_LOG_FUNCTION(level) \
- void wxLog##level(const wxChar *szFormat, ...) \
+ void wxLog##level(const wxChar *szFormat, va_list argptr) \
{ \
if ( IsLoggingEnabled() ) { \
wxCRIT_SECT_LOCKER(locker, gs_csLogBuf); \
\
- va_list argptr; \
- va_start(argptr, szFormat); \
wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr); \
- va_end(argptr); \
\
wxLog::OnLog(wxLOG_##level, s_szBuf, time(NULL)); \
} \
+ } \
+ void wxLog##level(const wxChar *szFormat, ...) \
+ { \
+ va_list argptr; \
+ va_start(argptr, szFormat); \
+ wxLog##level(szFormat, argptr); \
+ va_end(argptr); \
}
IMPLEMENT_LOG_FUNCTION(FatalError)
IMPLEMENT_LOG_FUNCTION(Status)
// same as info, but only if 'verbose' mode is on
-void wxLogVerbose(const wxChar *szFormat, ...)
+void wxLogVerbose(const wxChar *szFormat, va_list argptr)
{
if ( IsLoggingEnabled() ) {
wxLog *pLog = wxLog::GetActiveTarget();
if ( pLog != NULL && pLog->GetVerbose() ) {
wxCRIT_SECT_LOCKER(locker, gs_csLogBuf);
- va_list argptr;
- va_start(argptr, szFormat);
wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr);
- va_end(argptr);
wxLog::OnLog(wxLOG_Info, s_szBuf, time(NULL));
}
}
}
+void wxLogVerbose(const wxChar *szFormat, ...)
+{
+ va_list argptr;
+ va_start(argptr, szFormat);
+ wxLogVerbose(szFormat, argptr);
+ va_end(argptr);
+}
+
// debug functions
#ifdef __WXDEBUG__
#define IMPLEMENT_LOG_DEBUG_FUNCTION(level) \
- void wxLog##level(const wxChar *szFormat, ...) \
+ void wxLog##level(const wxChar *szFormat, va_list argptr) \
{ \
if ( IsLoggingEnabled() ) { \
wxCRIT_SECT_LOCKER(locker, gs_csLogBuf); \
\
- va_list argptr; \
- va_start(argptr, szFormat); \
wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr); \
- va_end(argptr); \
\
wxLog::OnLog(wxLOG_##level, s_szBuf, time(NULL)); \
} \
+ } \
+ void wxLog##level(const wxChar *szFormat, ...) \
+ { \
+ va_list argptr; \
+ va_start(argptr, szFormat); \
+ wxLog##level(szFormat, argptr); \
+ va_end(argptr); \
}
- void wxLogTrace(const wxChar *mask, const wxChar *szFormat, ...)
+ void wxLogTrace(const wxChar *mask, const wxChar *szFormat, va_list argptr)
{
if ( IsLoggingEnabled() && wxLog::IsAllowedTraceMask(mask) ) {
wxCRIT_SECT_LOCKER(locker, gs_csLogBuf);
len -= 2;
p += 2;
- va_list argptr;
- va_start(argptr, szFormat);
wxVsnprintf(p, len, szFormat, argptr);
- va_end(argptr);
-
+
wxLog::OnLog(wxLOG_Trace, s_szBuf, time(NULL));
}
}
- void wxLogTrace(wxTraceMask mask, const wxChar *szFormat, ...)
+ void wxLogTrace(const wxChar *mask, const wxChar *szFormat, ...)
+ {
+ va_list argptr;
+ va_start(argptr, szFormat);
+ wxLogTrace(mask, szFormat, argptr);
+ va_end(argptr);
+ }
+
+ void wxLogTrace(wxTraceMask mask, const wxChar *szFormat, 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 ( IsLoggingEnabled() && ((wxLog::GetTraceMask() & mask) == mask) ) {
wxCRIT_SECT_LOCKER(locker, gs_csLogBuf);
- va_list argptr;
- va_start(argptr, szFormat);
wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr);
- va_end(argptr);
wxLog::OnLog(wxLOG_Trace, s_szBuf, time(NULL));
}
}
+ void wxLogTrace(wxTraceMask mask, const wxChar *szFormat, ...)
+ {
+ va_list argptr;
+ va_start(argptr, szFormat);
+ wxLogTrace(mask, szFormat, argptr);
+ va_end(argptr);
+ }
+
#else // release
#define IMPLEMENT_LOG_DEBUG_FUNCTION(level)
#endif
wxLog::OnLog(wxLOG_Error, s_szBuf, time(NULL));
}
-void WXDLLEXPORT wxLogSysError(const wxChar *szFormat, ...)
+void WXDLLEXPORT wxLogSysError(const wxChar *szFormat, va_list argptr)
{
if ( IsLoggingEnabled() ) {
wxCRIT_SECT_LOCKER(locker, gs_csLogBuf);
- va_list argptr;
- va_start(argptr, szFormat);
wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr);
- va_end(argptr);
wxLogSysErrorHelper(wxSysErrorCode());
}
}
-void WXDLLEXPORT wxLogSysError(long lErrCode, const wxChar *szFormat, ...)
+void WXDLLEXPORT wxLogSysError(const wxChar *szFormat, ...)
+{
+ va_list argptr;
+ va_start(argptr, szFormat);
+ wxLogSysError(szFormat, argptr);
+ va_end(argptr);
+}
+
+void WXDLLEXPORT wxLogSysError(long lErrCode, const wxChar *szFormat, va_list argptr)
{
if ( IsLoggingEnabled() ) {
wxCRIT_SECT_LOCKER(locker, gs_csLogBuf);
- va_list argptr;
- va_start(argptr, szFormat);
wxVsnprintf(s_szBuf, WXSIZEOF(s_szBuf), szFormat, argptr);
- va_end(argptr);
wxLogSysErrorHelper(lErrCode);
}
}
+void WXDLLEXPORT wxLogSysError(long lErrCode, const wxChar *szFormat, ...)
+{
+ va_list argptr;
+ va_start(argptr, szFormat);
+ wxLogSysError(lErrCode, szFormat, argptr);
+ va_end(argptr);
+}
+
// ----------------------------------------------------------------------------
// wxLog class implementation
// ----------------------------------------------------------------------------