Buffered log-callback.

Allow a particular set of log messages to be retained indefinitely, for (presumably) later display somehow, such as in the GUI.
This commit is contained in:
James Turner
2013-02-07 13:01:56 +01:00
parent ab8373b989
commit f983194d7e
2 changed files with 75 additions and 1 deletions
+26 -1
View File
@@ -28,8 +28,12 @@
#include <simgear/compiler.h>
#include <simgear/debug/debug_types.h>
#include <vector>
#include <sstream>
#include <memory> // for std::auto_ptr
typedef std::vector<std::string> string_list;
// forward decls
class SGPath;
@@ -44,6 +48,27 @@ public:
const char* file, int line, const std::string& aMessage) = 0;
};
class BufferedLogCallback : public LogCallback
{
public:
BufferedLogCallback(sgDebugClass c, sgDebugPriority p);
virtual ~BufferedLogCallback();
virtual void operator()(sgDebugClass c, sgDebugPriority p,
const char* file, int line, const std::string& aMessage);
/**
* copy the buffered log data into the provided output list
* (which will be cleared first). This method is safe to call from
* any thread.
*/
void threadsafeCopy(string_list& aOutput);
private:
class BufferedLogCallbackPrivate;
std::auto_ptr<BufferedLogCallbackPrivate> d;
};
} // of namespace simgear
/**