简述
本次主要针对ros_log_sink.h
和ros_log_sin.cc
文件进行讲解。在这个类中主要完成了对于Google glog
消息的封装,使用ROS自带的日志消息输出宏来输出使用Google glog
中消息宏接受的消息。关于Google glog
的详细介绍请参考我的另外一篇文章google glog使用指南。
ros_log_sink.h
#ifndef CARTOGRAPHER_ROS_CARTOGRAPHER_ROS_ROS_LOG_SINK_H
#define CARTOGRAPHER_ROS_CARTOGRAPHER_ROS_ROS_LOG_SINK_H
#include <ctime>
#include "glog/logging.h"
namespace cartographer_ros {
// Makes Google logging use ROS logging for output while an instance of this
// class exists.
/**
* @brief 自定义的输出日志的方式: 使用ROS_INFO进行glog消息的输出
*/
class ScopedRosLogSink : public ::google::LogSink {
public:
ScopedRosLogSink();
~ScopedRosLogSink() override;
void send(::google::LogSeverity severity, const char* filename,
const char* base_filename, int line, const