log_message.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_TRACE_EVENT_LOG_MESSAGE_H_
  5. #define BASE_TRACE_EVENT_LOG_MESSAGE_H_
  6. #include <stddef.h>
  7. #include <memory>
  8. #include <string>
  9. #include <vector>
  10. #include "base/macros.h"
  11. #include "base/strings/string_piece.h"
  12. #include "base/trace_event/trace_event_impl.h"
  13. namespace base {
  14. class Value;
  15. namespace trace_event {
  16. class BASE_EXPORT LogMessage : public ConvertableToTraceFormat {
  17. public:
  18. LogMessage(const char* file, base::StringPiece message, int line);
  19. ~LogMessage() override;
  20. // ConvertableToTraceFormat class implementation.
  21. void AppendAsTraceFormat(std::string* out) const override;
  22. bool AppendToProto(ProtoAppender* appender) override;
  23. void EstimateTraceMemoryOverhead(TraceEventMemoryOverhead* overhead) override;
  24. const char* file() const { return file_; }
  25. const std::string& message() const { return message_; }
  26. int line_number() const { return line_number_; }
  27. private:
  28. const char* file_;
  29. std::string message_;
  30. int line_number_;
  31. DISALLOW_COPY_AND_ASSIGN(LogMessage);
  32. };
  33. } // namespace trace_event
  34. } // namespace base
  35. #endif // BASE_TRACE_EVENT_LOG_MESSAGE_H_