]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/log.h
removed wxTLW cruft now that all ports have it
[wxWidgets.git] / include / wx / log.h
index 2de7fe1e4b38a8f32af2edd87d253af50791bd0c..04efbd0bd80f539d682f76016050b9d4840975ac 100644 (file)
@@ -40,10 +40,20 @@ typedef unsigned long wxLogLevel;
 
 #if wxUSE_LOG
 
+#ifndef __WXWINCE__
 #include <time.h>   // for time_t
+#endif
 
 #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
 // ----------------------------------------------------------------------------
@@ -55,12 +65,13 @@ enum
     wxLOG_Error,      // a serious error, user must be informed about it
     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_Info,       // informational message (a.k.a. 'Verbose')
     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_Trace,      // trace messages are also only enabled in debug mode
     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 = 10000
 };
 
 // symbolic trace masks - wxLogTrace("foo", "some trace message...") will be
@@ -120,7 +131,7 @@ public:
     // derived classes
     static void OnLog(wxLogLevel level, const wxChar *szString, time_t t)
     {
-        if ( IsEnabled() ) {
+        if ( IsEnabled() && ms_logLevel >= level ) {
             wxLog *pLogger = GetActiveTarget();
             if ( pLogger )
                 pLogger->DoLog(level, szString, t);
@@ -165,6 +176,10 @@ public:
         // verbose mode is activated by standard command-line '-verbose'
         // option
     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
         // current is NULL?
     static void DontCreateOnDemand();
@@ -177,12 +192,15 @@ public:
     static void RemoveTraceMask(const wxString& str);
         // remove all string trace masks
     static void ClearTraceMasks();
+       // get string trace masks
+    static const wxArrayString &GetTraceMasks() { return ms_aTraceMasks; }
 
         // sets the timestamp string: this is used as strftime() format string
         // for the log targets which add time stamps to the messages - set it
         // to NULL to disable time stamping completely.
     static void SetTimestamp(const wxChar *ts) { ms_timestamp = ts; }
 
+
     // accessors
         // gets the verbose status
     static bool GetVerbose() { return ms_bVerbose; }
@@ -191,10 +209,13 @@ public:
         // is this trace mask in the list?
     static bool IsAllowedTraceMask(const wxChar *mask)
         { 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)
     static const wxChar *GetTimestamp() { return ms_timestamp; }
 
+
     // helpers
         // put the time stamp into the string if ms_timestamp != NULL (don't
         // change it otherwise)
@@ -223,6 +244,8 @@ private:
     static bool        ms_bAutoCreate;  // create new log targets on demand?
     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
 
     // format string for strftime(), if NULL, time stamping log messages is
@@ -346,6 +369,8 @@ private:
 
     // do we pass the messages to the old logger?
     bool m_bPassMessages;
+
+    DECLARE_NO_COPY_CLASS(wxLogChain)
 };
 
 // a chain log target which uses itself as the new logger
@@ -377,6 +402,8 @@ private:
 
     // the control we use
     wxTextCtrl *m_pTextCtrl;
+
+    DECLARE_NO_COPY_CLASS(wxLogTextCtrl)
 };
 
 #endif // wxUSE_TEXTCTRL
@@ -455,6 +482,8 @@ protected:
 
 private:
     wxLogFrame *m_pLogFrame;      // the log frame
+
+    DECLARE_NO_COPY_CLASS(wxLogWindow)
 };
 
 #endif // wxUSE_LOGWINDOW
@@ -537,7 +566,7 @@ DECLARE_LOG_FUNCTION(SysError);
 DECLARE_LOG_FUNCTION2(SysError, long lErrCode);
 
 // debug functions do nothing in release mode
-#ifdef  __WXDEBUG__
+#if wxUSE_LOG_DEBUG
     DECLARE_LOG_FUNCTION(Debug);
 
     // first kind of LogTrace is unconditional: it doesn't check the level,
@@ -596,3 +625,4 @@ void WXDLLEXPORT wxSafeShowMessage(const wxString& title, const wxString& text);
 
 #endif  // _WX_LOG_H_
 
+// vi:sts=4:sw=4:et