ros_logger.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD-3 License)
3  *
4  * Copyright (c) 2020 Jacob Willis.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * * Redistributions of source code must retain the above copyright notice, this
11  * list of conditions and the following disclaimer.
12  *
13  * * Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * * Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
38 #ifndef ROSFLIGHT_ROS_LOGGER_H
39 #define ROSFLIGHT_ROS_LOGGER_H
40 
42 
43 #include <ros/ros.h>
44 
45 namespace rosflight
46 {
54 class ROSLogger : public mavrosflight::LoggerInterface<ROSLogger>
55 {
56 public:
57  template <typename... Args>
58  inline void debug(const char* format, const Args&... args)
59  {
60 #pragma GCC diagnostic push
61 #pragma GCC diagnostic ignored "-Wformat-security"
62  ROS_DEBUG(format, args...);
63 #pragma GCC diagnostic pop
64  }
65  template <typename... Args>
66  inline void debug_throttle(float period, const char* format, const Args&... args)
67  {
68 #pragma GCC diagnostic push
69 #pragma GCC diagnostic ignored "-Wformat-security"
70  ROS_DEBUG_THROTTLE(period, format, args...);
71 #pragma GCC diagnostic pop
72  }
73 
74  template <typename... Args>
75  inline void info(const char* format, const Args&... args)
76  {
77 #pragma GCC diagnostic push
78 #pragma GCC diagnostic ignored "-Wformat-security"
79  ROS_INFO(format, args...);
80 #pragma GCC diagnostic pop
81  }
82  template <typename... Args>
83  inline void info_throttle(float period, const char* format, const Args&... args)
84  {
85 #pragma GCC diagnostic push
86 #pragma GCC diagnostic ignored "-Wformat-security"
87  ROS_INFO_THROTTLE(period, format, args...);
88 #pragma GCC diagnostic pop
89  }
90 
91  template <typename... Args>
92  inline void warn(const char* format, const Args&... args)
93  {
94 #pragma GCC diagnostic push
95 #pragma GCC diagnostic ignored "-Wformat-security"
96  ROS_WARN(format, args...);
97 #pragma GCC diagnostic pop
98  }
99  template <typename... Args>
100  inline void warn_throttle(float period, const char* format, const Args&... args)
101  {
102 #pragma GCC diagnostic push
103 #pragma GCC diagnostic ignored "-Wformat-security"
104  ROS_WARN_THROTTLE(period, format, args...);
105 #pragma GCC diagnostic pop
106  }
107 
108  template <typename... Args>
109  inline void error(const char* format, const Args&... args)
110  {
111 #pragma GCC diagnostic push
112 #pragma GCC diagnostic ignored "-Wformat-security"
113  ROS_ERROR(format, args...);
114 #pragma GCC diagnostic pop
115  }
116  template <typename... Args>
117  inline void error_throttle(float period, const char* format, const Args&... args)
118  {
119 #pragma GCC diagnostic push
120 #pragma GCC diagnostic ignored "-Wformat-security"
121  ROS_ERROR_THROTTLE(period, format, args...);
122 #pragma GCC diagnostic pop
123  }
124 
125  template <typename... Args>
126  inline void fatal(const char* format, const Args&... args)
127  {
128 #pragma GCC diagnostic push
129 #pragma GCC diagnostic ignored "-Wformat-security"
130  ROS_FATAL(format, args...);
131 #pragma GCC diagnostic pop
132  }
133  template <typename... Args>
134  inline void fatal_throttle(float period, const char* format, const Args&... args)
135  {
136 #pragma GCC diagnostic push
137 #pragma GCC diagnostic ignored "-Wformat-security"
138  ROS_FATAL_THROTTLE(period, format, args...);
139 #pragma GCC diagnostic pop
140  }
141 };
142 
143 } // namespace rosflight
144 
145 #endif // ROSFLIGHT_ROS_LOGGER_H
void fatal_throttle(float period, const char *format, const Args &...args)
Definition: ros_logger.h:134
void info_throttle(float period, const char *format, const Args &...args)
Definition: ros_logger.h:83
#define ROS_FATAL(...)
#define ROS_WARN_THROTTLE(rate,...)
#define ROS_DEBUG_THROTTLE(rate,...)
void debug_throttle(float period, const char *format, const Args &...args)
Definition: ros_logger.h:66
void debug(const char *format, const Args &...args)
Definition: ros_logger.h:58
#define ROS_WARN(...)
#define ROS_ERROR_THROTTLE(rate,...)
Abstract base class for message handler.
#define ROS_FATAL_THROTTLE(rate,...)
void error(const char *format, const Args &...args)
Definition: ros_logger.h:109
#define ROS_INFO(...)
void warn_throttle(float period, const char *format, const Args &...args)
Definition: ros_logger.h:100
#define ROS_INFO_THROTTLE(rate,...)
void error_throttle(float period, const char *format, const Args &...args)
Definition: ros_logger.h:117
void fatal(const char *format, const Args &...args)
Definition: ros_logger.h:126
void info(const char *format, const Args &...args)
Definition: ros_logger.h:75
#define ROS_ERROR(...)
void warn(const char *format, const Args &...args)
Definition: ros_logger.h:92
#define ROS_DEBUG(...)
Logger implementation for ROS environments.
Definition: ros_logger.h:54


rosflight
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Apr 15 2021 05:09:26