Apollo 10.0
自动驾驶开放平台
monitor_log_buffer.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
22#pragma once
23
24#include <memory>
25#include <sstream>
26#include <string>
27#include <utility>
28#include <vector>
29
30#include "gtest/gtest_prod.h"
32#include "modules/common_msgs/monitor_msgs/monitor_log.pb.h"
33
38namespace apollo {
39namespace common {
40namespace monitor {
41
42#define REG_MSG_TYPE(TYPE) \
43 MonitorLogBuffer &TYPE(const std::string &msg) { \
44 AddMonitorMsgItem(MonitorMessageItem::TYPE, msg); \
45 Publish(); \
46 return *this; \
47 } \
48 MonitorLogBuffer &TYPE() { \
49 level_ = MonitorMessageItem::TYPE; \
50 return *this; \
51 }
52
61 public:
67
68 virtual ~MonitorLogBuffer();
69
74
79
84
89
96 const std::string &msg);
97
101 void Publish();
102
103 private:
104 MonitorLogger *logger_ = MonitorLogger::Instance();
106 std::vector<MessageItem> monitor_msg_items_;
108
109 FRIEND_TEST(MonitorBufferTest, RegisterMacro);
110 FRIEND_TEST(MonitorBufferTest, AddMonitorMsgItem);
111 FRIEND_TEST(MonitorBufferTest, Operator);
112};
113
114} // namespace monitor
115} // namespace common
116} // namespace apollo
REG_MSG_TYPE(WARN)
record a WARN type message
REG_MSG_TYPE(ERROR)
record an ERROR type message
REG_MSG_TYPE(FATAL)
record a FATAL type message
void AddMonitorMsgItem(const MonitorMessageItem::LogLevel log_level, const std::string &msg)
Add monitor message with MonitorMessageItem::LogLevel
REG_MSG_TYPE(INFO)
record an INFO type message
void Publish()
publish the monitor messages
The class of MonitorLogger
class register implement
Definition arena_queue.h:37