log_wrapper.h
Go to the documentation of this file.
1 /*
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2011, Southwest Research Institute
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
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * * Neither the name of the Southwest Research Institute, nor the names
16 * of its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31 
32 #ifndef LOG_WRAPPER_H_
33 #define LOG_WRAPPER_H_
34 
35 // remove ROS after Melodic (bw compat for #262)
36 #if defined(SIMPLE_MESSAGE_USE_ROS) || defined(ROS)
37 #include "ros/ros.h"
38 #endif
39 
40 #ifdef SIMPLE_MESSAGE_MOTOPLUS
41 #include "motoPlus.h"
42 #endif
43 
44 namespace industrial
45 {
46 
54 namespace log_wrapper
55 {
56 
57 
58 // Define ROS if this library will execute under ROS
59 // remove ROS after Melodic (bw compat for #262)
60 #if defined(SIMPLE_MESSAGE_USE_ROS) || defined(ROS)
61 
62 // The LOG_COMM redirects to debug in ROS because ROS has
63 // debug filtering tools that allow the communications messages
64 // to be easily removed from the logs
65 #ifdef _MSC_VER
66 
67 #define LOG_COMM(...) \
68  ROS_DEBUG(__VA_ARGS__)
69 
70 #define LOG_DEBUG(...) \
71  ROS_DEBUG(__VA_ARGS__)
72 
73 #define LOG_INFO(...) \
74  ROS_INFO(__VA_ARGS__)
75 
76 #define LOG_WARN(...) \
77  ROS_WARN(__VA_ARGS__)
78 
79 #define LOG_ERROR(...) \
80  ROS_ERROR(__VA_ARGS__)
81 
82 #define LOG_FATAL(...) \
83  ROS_FATAL(__VA_ARGS__)
84 
85 #else
86 
87 #define LOG_COMM(format, ...) \
88  ROS_DEBUG(format, ##__VA_ARGS__)
89 
90 #define LOG_DEBUG(format, ...) \
91  ROS_DEBUG(format, ##__VA_ARGS__)
92 
93 #define LOG_INFO(format, ...) \
94  ROS_INFO(format, ##__VA_ARGS__)
95 
96 #define LOG_WARN(format, ...) \
97  ROS_WARN(format, ##__VA_ARGS__)
98 
99 #define LOG_ERROR(format, ...) \
100  ROS_ERROR(format, ##__VA_ARGS__)
101 
102 #define LOG_FATAL(format, ...) \
103  ROS_FATAL(FATAL, ##__VA_ARGS__)
104 
105 #endif
106 
107 #elif defined(STDIOLOG)
108 
109 #define LOG(level, format, ...) \
110 do \
111 { \
112  printf(level); \
113  printf(": "); \
114  printf(format, ##__VA_ARGS__); \
115  printf("\n"); \
116  } while (0)
117 
118 // WARNING: LOG_COMM produces many messages and could slow down program
119 // execution on the robot.
120 #define LOG_COMM(format, ...) LOG("COMM", format, ##__VA_ARGS__)
121 #define LOG_DEBUG(format, ...) LOG("DEBUG", format, ##__VA_ARGS__)
122 #define LOG_INFO(format, ...) LOG("INFO", format, ##__VA_ARGS__)
123 #define LOG_WARN(format, ...) LOG("WARNING", format, ##__VA_ARGS__)
124 #define LOG_ERROR(format, ...) LOG("ERROR", format, ##__VA_ARGS__)
125 #define LOG_FATAL(format, ...) LOG("FATAL", format, ##__VA_ARGS__)
126 
127 #else
128 // LOG DISABLED
129 
130 #define LOG_COMM(format, ...)
131 #define LOG_DEBUG(format, ...)
132 #define LOG_INFO(format, ...)
133 #define LOG_WARN(format, ...)
134 #define LOG_ERROR(format, ...)
135 #define LOG_FATAL(format, ...)
136 
137 #endif
138 
139 
140 
141 } // namespace industrial
142 } // namespace loge_wrapper
143 
144 #endif /* LOG_WRAPPER_H_ */
ros.h
industrial
Definition: byte_array.h:45


simple_message
Author(s): Shaun Edwards
autogenerated on Wed Mar 2 2022 00:24:53