#include <simgear/debug/debug_types.h>
#include <sstream>
+#include <vector>
// forward decls
class SGPath;
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
/**
class logstream
{
public:
+ ~logstream();
+
static void initGlobalLogstream();
/**
* Set the global log class and priority level.
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.
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__)