]> git.mxchange.org Git - simgear.git/blobdiff - simgear/debug/logstream.hxx
Merge branch 'next' of git.mxchange.org:/var/cache/git/repos/simgear into next
[simgear.git] / simgear / debug / logstream.hxx
index 0af98c6a71a7d05dc5be344d6308e7c219b8c746..4e2771b9989857923be633eaf92019f3234a0a05 100644 (file)
@@ -29,6 +29,7 @@
 #include <simgear/debug/debug_types.h>
 
 #include <sstream>
+#include <vector>
  
 // forward decls
 class SGPath;
@@ -42,8 +43,26 @@ public:
     virtual ~LogCallback() {}
     virtual void operator()(sgDebugClass c, sgDebugPriority p, 
         const char* file, int line, const std::string& aMessage) = 0;
+
+       void setLogLevels(sgDebugClass c, sgDebugPriority p);
+protected:
+       LogCallback(sgDebugClass c, sgDebugPriority p);
+
+       bool shouldLog(sgDebugClass c, sgDebugPriority p) const;
+private:
+       sgDebugClass m_class;
+       sgDebugPriority m_priority;
 };
-     
+
+/**
+ * Helper force a console on platforms where it might optional, when
+ * we need to show a console. This basically means Windows at the
+ * moment - on other plaforms it's a no-op
+ */
+void requestConsole();
+
+void shutdownLogging();
+
 } // of namespace simgear
 
 /**
@@ -52,6 +71,8 @@ public:
 class logstream
 {
 public:
+    ~logstream();
+    
     static void initGlobalLogstream();
     /**
      * Set the global log class and priority level.
@@ -78,6 +99,23 @@ public:
     void log( sgDebugClass c, sgDebugPriority p,
             const char* fileName, int line, const std::string& msg);
 
+    /**
+     * support for the SG_POPUP logging class
+     * set the content of the popup message
+     */
+    void popup( const std::string& msg);
+
+    /**
+     * retrieve the contents of the popup message and clear it's internal
+     * content. The return value may be an empty string.
+     */
+    std::string get_popup();
+
+    /**
+     * return true if a new popup message is available. false otherwise.
+     */
+    bool has_popup();
+
    /**
     * \relates logstream
     * Return the one and only logstream instance.
@@ -99,26 +137,30 @@ public:
 private:
     // constructor
     logstream();
+
+    std::vector<std::string> popup_msgs;
 };
 
 logstream& sglog();
 
+
+
 /** \def SG_LOG(C,P,M)
  * Log a message.
  * @param C debug class
  * @param P priority
  * @param M message
  */
+# define SG_LOGX(C,P,M) \
+    do { if(sglog().would_log(C,P)) {                         \
+        std::ostringstream os; os << M;                  \
+        sglog().log(C, P, __FILE__, __LINE__, os.str()); \
+        if (P == SG_POPUP) sglog().popup(os.str());      \
+    } } while(0)
 #ifdef FG_NDEBUG
-# define SG_LOG(C,P,M)
+# define SG_LOG(C,P,M) do { if(P == SG_POPUP) SG_LOGX(C,P,M) } while(0)
 #else
-# define SG_LOG(C,P,M) do {                     \
-       if(sglog().would_log(C,P)) {                      \
-        std::ostringstream os;                             \
-        os << M;                                       \
-        sglog().log(C, P, __FILE__, __LINE__, os.str()); \
-    } \
-} while(0)
+# define SG_LOG(C,P,M) SG_LOGX(C,P,M)
 #endif
 
 #define SG_ORIGIN __FILE__ ":" SG_STRINGIZE(__LINE__)