Added wxLog::Get/SetLogLevel
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@18474 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -314,6 +314,19 @@ logged as the normal ones instead of being silently dropped.
|
|||||||
|
|
||||||
Returns whether the verbose mode is currently active.
|
Returns whether the verbose mode is currently active.
|
||||||
|
|
||||||
|
\membersection{wxLog::SetLogLevel}\label{wxlogsetloglevel}
|
||||||
|
|
||||||
|
\func{static void}{SetLogLevel}{\param{wxLogLevel }{ logLevel}}
|
||||||
|
|
||||||
|
Specifies that log messages with $level > logLevel$ should be ignored
|
||||||
|
and not sent to the active log target.
|
||||||
|
|
||||||
|
\membersection{wxLog::GetLogLevel}\label{wxloggetloglevel}
|
||||||
|
|
||||||
|
\func{static wxLogLevel}{GetLogLevel}{\void}
|
||||||
|
|
||||||
|
Returns the current log level limit.
|
||||||
|
|
||||||
\membersection{wxLog::SetTimestamp}\label{wxlogsettimestamp}
|
\membersection{wxLog::SetTimestamp}\label{wxlogsettimestamp}
|
||||||
|
|
||||||
\func{void}{SetTimestamp}{\param{const char * }{ format}}
|
\func{void}{SetTimestamp}{\param{const char * }{ format}}
|
||||||
|
@@ -44,6 +44,14 @@ typedef unsigned long wxLogLevel;
|
|||||||
|
|
||||||
#include "wx/dynarray.h"
|
#include "wx/dynarray.h"
|
||||||
|
|
||||||
|
#ifndef wxUSE_LOG_DEBUG
|
||||||
|
# ifdef __WXDEBUG__
|
||||||
|
# define wxUSE_LOG_DEBUG 1
|
||||||
|
# else // !__WXDEBUG__
|
||||||
|
# define wxUSE_LOG_DEBUG 0
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// constants
|
// constants
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -55,12 +63,13 @@ enum
|
|||||||
wxLOG_Error, // a serious error, user must be informed about it
|
wxLOG_Error, // a serious error, user must be informed about it
|
||||||
wxLOG_Warning, // user is normally informed about it but may be ignored
|
wxLOG_Warning, // user is normally informed about it but may be ignored
|
||||||
wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
|
wxLOG_Message, // normal message (i.e. normal output of a non GUI app)
|
||||||
wxLOG_Info, // informational message (a.k.a. 'Verbose')
|
|
||||||
wxLOG_Status, // informational: might go to the status line of GUI app
|
wxLOG_Status, // informational: might go to the status line of GUI app
|
||||||
|
wxLOG_Info, // informational message (a.k.a. 'Verbose')
|
||||||
wxLOG_Debug, // never shown to the user, disabled in release mode
|
wxLOG_Debug, // never shown to the user, disabled in release mode
|
||||||
wxLOG_Trace, // trace messages are also only enabled in debug mode
|
wxLOG_Trace, // trace messages are also only enabled in debug mode
|
||||||
wxLOG_Progress, // used for progress indicator (not yet)
|
wxLOG_Progress, // used for progress indicator (not yet)
|
||||||
wxLOG_User = 100 // user defined levels start here
|
wxLOG_User = 100, // user defined levels start here
|
||||||
|
wxLOG_Max = UINT_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
// symbolic trace masks - wxLogTrace("foo", "some trace message...") will be
|
// symbolic trace masks - wxLogTrace("foo", "some trace message...") will be
|
||||||
@@ -120,7 +129,7 @@ public:
|
|||||||
// derived classes
|
// derived classes
|
||||||
static void OnLog(wxLogLevel level, const wxChar *szString, time_t t)
|
static void OnLog(wxLogLevel level, const wxChar *szString, time_t t)
|
||||||
{
|
{
|
||||||
if ( IsEnabled() ) {
|
if ( IsEnabled() && ms_logLevel >= level ) {
|
||||||
wxLog *pLogger = GetActiveTarget();
|
wxLog *pLogger = GetActiveTarget();
|
||||||
if ( pLogger )
|
if ( pLogger )
|
||||||
pLogger->DoLog(level, szString, t);
|
pLogger->DoLog(level, szString, t);
|
||||||
@@ -165,6 +174,10 @@ public:
|
|||||||
// verbose mode is activated by standard command-line '-verbose'
|
// verbose mode is activated by standard command-line '-verbose'
|
||||||
// option
|
// option
|
||||||
static void SetVerbose(bool bVerbose = TRUE) { ms_bVerbose = bVerbose; }
|
static void SetVerbose(bool bVerbose = TRUE) { ms_bVerbose = bVerbose; }
|
||||||
|
|
||||||
|
// Set log level. Log messages with level > logLevel will not be logged.
|
||||||
|
static void SetLogLevel(wxLogLevel logLevel) { ms_logLevel = logLevel; }
|
||||||
|
|
||||||
// should GetActiveTarget() try to create a new log object if the
|
// should GetActiveTarget() try to create a new log object if the
|
||||||
// current is NULL?
|
// current is NULL?
|
||||||
static void DontCreateOnDemand();
|
static void DontCreateOnDemand();
|
||||||
@@ -185,6 +198,7 @@ public:
|
|||||||
// to NULL to disable time stamping completely.
|
// to NULL to disable time stamping completely.
|
||||||
static void SetTimestamp(const wxChar *ts) { ms_timestamp = ts; }
|
static void SetTimestamp(const wxChar *ts) { ms_timestamp = ts; }
|
||||||
|
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
// gets the verbose status
|
// gets the verbose status
|
||||||
static bool GetVerbose() { return ms_bVerbose; }
|
static bool GetVerbose() { return ms_bVerbose; }
|
||||||
@@ -193,10 +207,13 @@ public:
|
|||||||
// is this trace mask in the list?
|
// is this trace mask in the list?
|
||||||
static bool IsAllowedTraceMask(const wxChar *mask)
|
static bool IsAllowedTraceMask(const wxChar *mask)
|
||||||
{ return ms_aTraceMasks.Index(mask) != wxNOT_FOUND; }
|
{ return ms_aTraceMasks.Index(mask) != wxNOT_FOUND; }
|
||||||
|
// return the current loglevel limit
|
||||||
|
static wxLogLevel GetLogLevel() { return ms_logLevel; }
|
||||||
|
|
||||||
// get the current timestamp format string (may be NULL)
|
// get the current timestamp format string (may be NULL)
|
||||||
static const wxChar *GetTimestamp() { return ms_timestamp; }
|
static const wxChar *GetTimestamp() { return ms_timestamp; }
|
||||||
|
|
||||||
|
|
||||||
// helpers
|
// helpers
|
||||||
// put the time stamp into the string if ms_timestamp != NULL (don't
|
// put the time stamp into the string if ms_timestamp != NULL (don't
|
||||||
// change it otherwise)
|
// change it otherwise)
|
||||||
@@ -225,6 +242,8 @@ private:
|
|||||||
static bool ms_bAutoCreate; // create new log targets on demand?
|
static bool ms_bAutoCreate; // create new log targets on demand?
|
||||||
static bool ms_bVerbose; // FALSE => ignore LogInfo messages
|
static bool ms_bVerbose; // FALSE => ignore LogInfo messages
|
||||||
|
|
||||||
|
static wxLogLevel ms_logLevel; // limit logging to levels <= ms_logLevel
|
||||||
|
|
||||||
static size_t ms_suspendCount; // if positive, logs are not flushed
|
static size_t ms_suspendCount; // if positive, logs are not flushed
|
||||||
|
|
||||||
// format string for strftime(), if NULL, time stamping log messages is
|
// format string for strftime(), if NULL, time stamping log messages is
|
||||||
@@ -539,7 +558,7 @@ DECLARE_LOG_FUNCTION(SysError);
|
|||||||
DECLARE_LOG_FUNCTION2(SysError, long lErrCode);
|
DECLARE_LOG_FUNCTION2(SysError, long lErrCode);
|
||||||
|
|
||||||
// debug functions do nothing in release mode
|
// debug functions do nothing in release mode
|
||||||
#ifdef __WXDEBUG__
|
#if wxUSE_LOG_DEBUG
|
||||||
DECLARE_LOG_FUNCTION(Debug);
|
DECLARE_LOG_FUNCTION(Debug);
|
||||||
|
|
||||||
// first kind of LogTrace is unconditional: it doesn't check the level,
|
// first kind of LogTrace is unconditional: it doesn't check the level,
|
||||||
|
@@ -845,6 +845,8 @@ bool wxLog::ms_doLog = TRUE;
|
|||||||
bool wxLog::ms_bAutoCreate = TRUE;
|
bool wxLog::ms_bAutoCreate = TRUE;
|
||||||
bool wxLog::ms_bVerbose = FALSE;
|
bool wxLog::ms_bVerbose = FALSE;
|
||||||
|
|
||||||
|
wxLogLevel wxLog::ms_logLevel = wxLOG_Max; // log everything by default
|
||||||
|
|
||||||
size_t wxLog::ms_suspendCount = 0;
|
size_t wxLog::ms_suspendCount = 0;
|
||||||
|
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
|
Reference in New Issue
Block a user