diff options
Diffstat (limited to 'include/lldb/Core/Log.h')
-rw-r--r-- | include/lldb/Core/Log.h | 140 |
1 files changed, 60 insertions, 80 deletions
diff --git a/include/lldb/Core/Log.h b/include/lldb/Core/Log.h index b389946e264c..3aa4b4d48e17 100644 --- a/include/lldb/Core/Log.h +++ b/include/lldb/Core/Log.h @@ -22,20 +22,10 @@ #include "lldb/lldb-private.h" #include "lldb/Core/ConstString.h" #include "lldb/Core/Flags.h" +#include "lldb/Core/Logging.h" #include "lldb/Core/PluginInterface.h" //---------------------------------------------------------------------- -// Logging types -//---------------------------------------------------------------------- -#define LLDB_LOG_FLAG_STDOUT (1u << 0) -#define LLDB_LOG_FLAG_STDERR (1u << 1) -#define LLDB_LOG_FLAG_FATAL (1u << 2) -#define LLDB_LOG_FLAG_ERROR (1u << 3) -#define LLDB_LOG_FLAG_WARNING (1u << 4) -#define LLDB_LOG_FLAG_DEBUG (1u << 5) -#define LLDB_LOG_FLAG_VERBOSE (1u << 6) - -//---------------------------------------------------------------------- // Logging Options //---------------------------------------------------------------------- #define LLDB_LOG_OPTION_THREADSAFE (1u << 0) @@ -46,6 +36,7 @@ #define LLDB_LOG_OPTION_PREPEND_PROC_AND_THREAD (1u << 5) #define LLDB_LOG_OPTION_PREPEND_THREAD_NAME (1U << 6) #define LLDB_LOG_OPTION_BACKTRACE (1U << 7) +#define LLDB_LOG_OPTION_APPEND (1U << 8) //---------------------------------------------------------------------- // Logging Functions @@ -59,12 +50,10 @@ public: //------------------------------------------------------------------ // Callback definitions for abstracted plug-in log access. //------------------------------------------------------------------ - typedef void (*DisableCallback) (const char **categories, Stream *feedback_strm); - typedef Log * (*EnableCallback) (lldb::StreamSP &log_stream_sp, - uint32_t log_options, - const char **categories, - Stream *feedback_strm); - typedef void (*ListCategoriesCallback) (Stream *strm); + typedef void (*DisableCallback)(const char **categories, Stream *feedback_strm); + typedef Log *(*EnableCallback)(lldb::StreamSP &log_stream_sp, uint32_t log_options, const char **categories, + Stream *feedback_strm); + typedef void (*ListCategoriesCallback)(Stream *strm); struct Callbacks { @@ -77,86 +66,85 @@ public: // Static accessors for logging channels //------------------------------------------------------------------ static void - RegisterLogChannel (const ConstString &channel, - const Log::Callbacks &log_callbacks); + RegisterLogChannel(const ConstString &channel, const Log::Callbacks &log_callbacks); static bool - UnregisterLogChannel (const ConstString &channel); + UnregisterLogChannel(const ConstString &channel); static bool - GetLogChannelCallbacks (const ConstString &channel, - Log::Callbacks &log_callbacks); + GetLogChannelCallbacks(const ConstString &channel, Log::Callbacks &log_callbacks); + static bool + EnableLogChannel(lldb::StreamSP &log_stream_sp, uint32_t log_options, const char *channel, + const char **categories, Stream &error_stream); static void - EnableAllLogChannels (lldb::StreamSP &log_stream_sp, - uint32_t log_options, - const char **categories, - Stream *feedback_strm); + EnableAllLogChannels(lldb::StreamSP &log_stream_sp, uint32_t log_options, const char **categories, + Stream *feedback_strm); static void - DisableAllLogChannels (Stream *feedback_strm); + DisableAllLogChannels(Stream *feedback_strm); static void - ListAllLogChannels (Stream *strm); + ListAllLogChannels(Stream *strm); static void - Initialize (); + Initialize(); static void - Terminate (); - + Terminate(); + //------------------------------------------------------------------ // Auto completion //------------------------------------------------------------------ static void - AutoCompleteChannelName (const char *channel_name, - StringList &matches); + AutoCompleteChannelName(const char *channel_name, StringList &matches); //------------------------------------------------------------------ // Member functions //------------------------------------------------------------------ - Log (); + Log(); - Log (const lldb::StreamSP &stream_sp); + Log(const lldb::StreamSP &stream_sp); - ~Log (); + virtual + ~Log(); - void - PutCString (const char *cstr); + virtual void + PutCString(const char *cstr); - void - Printf (const char *format, ...) __attribute__ ((format (printf, 2, 3))); + virtual void + Printf(const char *format, ...) __attribute__((format(printf, 2, 3))); - void - VAPrintf (const char *format, va_list args); + virtual void + VAPrintf(const char *format, va_list args); - void - PrintfWithFlags( uint32_t flags, const char *format, ...) __attribute__ ((format (printf, 3, 4))); + virtual void + LogIf(uint32_t mask, const char *fmt, ...) __attribute__((format(printf, 3, 4))); - void - LogIf (uint32_t mask, const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); + virtual void + Debug(const char *fmt, ...) __attribute__((format(printf, 2, 3))); - void - Debug (const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); + virtual void + DebugVerbose(const char *fmt, ...) __attribute__((format(printf, 2, 3))); - void - DebugVerbose (const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); + virtual void + Error(const char *fmt, ...) __attribute__((format(printf, 2, 3))); - void - Error (const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); + virtual void + VAError(const char *format, va_list args); - void - FatalError (int err, const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); + virtual void + FatalError(int err, const char *fmt, ...) __attribute__((format(printf, 3, 4))); - void - Verbose (const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); + virtual void + Verbose(const char *fmt, ...) __attribute__((format(printf, 2, 3))); - void - Warning (const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); + virtual void + Warning(const char *fmt, ...) __attribute__((format(printf, 2, 3))); - void - WarningVerbose (const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); + virtual void + WarningVerbose(const char *fmt, ...) __attribute__((format(printf, 2, 3))); Flags & GetOptions(); @@ -177,7 +165,7 @@ public: GetDebug() const; void - SetStream (const lldb::StreamSP &stream_sp) + SetStream(const lldb::StreamSP &stream_sp) { m_stream_sp = stream_sp; } @@ -190,43 +178,35 @@ protected: Flags m_options; Flags m_mask_bits; - void - PrintfWithFlagsVarArg (uint32_t flags, const char *format, va_list args); - private: - DISALLOW_COPY_AND_ASSIGN (Log); + DISALLOW_COPY_AND_ASSIGN(Log); }; class LogChannel : public PluginInterface { public: - LogChannel (); + LogChannel(); - virtual - ~LogChannel (); + virtual ~LogChannel(); - static lldb::LogChannelSP - FindPlugin (const char *plugin_name); + static lldb::LogChannelSP FindPlugin(const char *plugin_name); // categories is a an array of chars that ends with a NULL element. - virtual void - Disable (const char **categories, Stream *feedback_strm) = 0; + virtual void Disable(const char **categories, Stream *feedback_strm) = 0; - virtual bool - Enable (lldb::StreamSP &log_stream_sp, - uint32_t log_options, - Stream *feedback_strm, // Feedback stream for argument errors etc - const char **categories) = 0;// The categories to enable within this logging stream, if empty, enable default set + virtual bool Enable( + lldb::StreamSP &log_stream_sp, uint32_t log_options, + Stream *feedback_strm, // Feedback stream for argument errors etc + const char **categories) = 0; // The categories to enable within this logging stream, if empty, enable default set - virtual void - ListCategories (Stream *strm) = 0; + virtual void ListCategories(Stream *strm) = 0; protected: std::unique_ptr<Log> m_log_ap; private: - DISALLOW_COPY_AND_ASSIGN (LogChannel); + DISALLOW_COPY_AND_ASSIGN(LogChannel); }; |