1 //===-- LogMessageOsLog.h ---------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLDB_TOOLS_DEBUGSERVER_SOURCE_MACOSX_DARWINLOG_LOGMESSAGEOSLOG_H 10 #define LLDB_TOOLS_DEBUGSERVER_SOURCE_MACOSX_DARWINLOG_LOGMESSAGEOSLOG_H 11 12 #include "DarwinLogInterfaces.h" 13 14 #include "ActivityStreamSPI.h" 15 #include "LogMessage.h" 16 17 using ActivityStreamEntry = struct os_activity_stream_entry_s; 18 19 /// Provides a unified wrapper around os_log()-style log messages. 20 /// 21 /// The lifetime of this class is intended to be very short. The caller 22 /// must ensure that the passed in ActivityStore and ActivityStreamEntry 23 /// outlive this LogMessageOsLog entry. 24 25 class LogMessageOsLog : public LogMessage { 26 public: 27 static void SetFormatterFunction(os_log_copy_formatted_message_t format_func); 28 29 LogMessageOsLog(const ActivityStore &activity_store, 30 ActivityStreamEntry &entry); 31 32 // API methods 33 34 bool HasActivity() const override; 35 36 const char *GetActivity() const override; 37 38 std::string GetActivityChain() const override; 39 40 bool HasCategory() const override; 41 42 const char *GetCategory() const override; 43 44 bool HasSubsystem() const override; 45 46 const char *GetSubsystem() const override; 47 48 const char *GetMessage() const override; 49 50 private: 51 const ActivityStore &m_activity_store; 52 ActivityStreamEntry &m_entry; 53 mutable std::string m_message; 54 }; 55 56 #endif // LLDB_TOOLS_DEBUGSERVER_SOURCE_MACOSX_DARWINLOG_LOGMESSAGEOSLOG_H 57