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 #ifdef ROS
36 #include "ros/ros.h"
37 #endif
38 
39 #ifdef MOTOPLUS
40 #include "motoPlus.h"
41 #endif
42 
43 namespace industrial
44 {
45 
53 namespace log_wrapper
54 {
55 
56 
57 // Define ROS if this library will execute under ROS
58 #ifdef ROS
59 
60 // The LOG_COMM redirects to debug in ROS because ROS has
61 // debug filtering tools that allow the communications messages
62 // to be easily removed from the logs
63 #define LOG_COMM(format, ...) \
64  ROS_DEBUG(format, ##__VA_ARGS__)
65 
66 #define LOG_DEBUG(format, ...) \
67  ROS_DEBUG(format, ##__VA_ARGS__)
68 
69 #define LOG_INFO(format, ...) \
70  ROS_INFO(format, ##__VA_ARGS__)
71 
72 #define LOG_WARN(format, ...) \
73  ROS_WARN(format, ##__VA_ARGS__)
74 
75 #define LOG_ERROR(format, ...) \
76  ROS_ERROR(format, ##__VA_ARGS__)
77 
78 #define LOG_FATAL(format, ...) \
79  ROS_FATAL(FATAL, ##__VA_ARGS__)
80 
81 #elif defined(STDIOLOG)
82 
83 #define LOG(level, format, ...) \
84 do \
85 { \
86  printf(level); \
87  printf(": "); \
88  printf(format, ##__VA_ARGS__); \
89  printf("\n"); \
90  } while (0)
91 
92 // WARNING: LOG_COMM produces many messages and could slow down program
93 // execution on the robot.
94 #define LOG_COMM(format, ...) LOG("COMM", format, ##__VA_ARGS__)
95 #define LOG_DEBUG(format, ...) LOG("DEBUG", format, ##__VA_ARGS__)
96 #define LOG_INFO(format, ...) LOG("INFO", format, ##__VA_ARGS__)
97 #define LOG_WARN(format, ...) LOG("WARNING", format, ##__VA_ARGS__)
98 #define LOG_ERROR(format, ...) LOG("ERROR", format, ##__VA_ARGS__)
99 #define LOG_FATAL(format, ...) LOG("FATAL", format, ##__VA_ARGS__)
100 
101 #else
102 // LOG DISABLED
103 
104 #define LOG_COMM(format, ...)
105 #define LOG_DEBUG(format, ...)
106 #define LOG_INFO(format, ...)
107 #define LOG_WARN(format, ...)
108 #define LOG_ERROR(format, ...)
109 #define LOG_FATAL(format, ...)
110 
111 #endif
112 
113 
114 
115 } // namespace industrial
116 } // namespace loge_wrapper
117 
118 #endif /* LOG_WRAPPER_H_ */


simple_message
Author(s): Shaun Edwards
autogenerated on Sat Sep 21 2019 03:30:09