From 512ebc2ac144111702171d7ac8c6a1eb2d25b650 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Tue, 3 Mar 2015 16:43:50 -0500 Subject: Add a logging system --- binaryninjaapi.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'binaryninjaapi.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 2c031b89..2b0d53ad 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -124,6 +124,33 @@ namespace BinaryNinja } }; + class LogListener + { + static void LogMessageCallback(void* ctxt, BNLogLevel level, const char* msg); + static void CloseLogCallback(void* ctxt); + + public: + virtual ~LogListener() {} + + static void RegisterLogListener(LogListener* listener); + static void UnregisterLogListener(LogListener* listener); + + virtual void LogMessage(BNLogLevel level, const std::string& msg) = 0; + virtual void CloseLog() {} + }; + + void Log(BNLogLevel level, const char* fmt, ...); + void LogDebug(const char* fmt, ...); + void LogInfo(const char* fmt, ...); + void LogWarn(const char* fmt, ...); + void LogError(const char* fmt, ...); + void LogAlert(const char* fmt, ...); + + void LogToStdout(BNLogLevel minimumLevel); + void LogToStderr(BNLogLevel minimumLevel); + bool LogToFile(BNLogLevel minimumLevel, const std::string& path, bool append = false); + void CloseLogs(); + class DataBuffer { BNDataBuffer* m_buffer; -- cgit v1.3.1