Robotis Manipulator  1.0.0
robotis_manipulator_log.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright 2018 ROBOTIS CO., LTD.
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 
17 /* Authors: Darby Lim, Hye-Jong KIM, Ryan Shim, Yong-Ho Na */
18 
26 #include "../../include/robotis_manipulator/robotis_manipulator_log.h"
27 
29 {
30 #if defined(__OPENCR__)
31  DEBUG.print(str);
32 #else
33  if(color == "RED") printf(ANSI_COLOR_RED);
34  else if(color == "GREEN") printf(ANSI_COLOR_GREEN);
35  else if(color == "YELLOW") printf(ANSI_COLOR_YELLOW);
36  else if(color == "BLUE") printf(ANSI_COLOR_BLUE);
37  else if(color == "MAGENTA") printf(ANSI_COLOR_MAGENTA);
38  else if(color == "CYAN") printf(ANSI_COLOR_CYAN);
39  printf("%s", str.c_str());
40  printf(ANSI_COLOR_RESET);
41 #endif
42 }
43 void robotis_manipulator::log::print(STRING str, double data, uint8_t decimal_point, STRING color)
44 {
45 #if defined(__OPENCR__)
46  DEBUG.print(str);
47  DEBUG.print(data, decimal_point);
48 #else
49  if(color == "RED") printf(ANSI_COLOR_RED);
50  else if(color == "GREEN") printf(ANSI_COLOR_GREEN);
51  else if(color == "YELLOW") printf(ANSI_COLOR_YELLOW);
52  else if(color == "BLUE") printf(ANSI_COLOR_BLUE);
53  else if(color == "MAGENTA") printf(ANSI_COLOR_MAGENTA);
54  else if(color == "CYAN") printf(ANSI_COLOR_CYAN);
55  printf("%s %.*lf", str.c_str(), decimal_point, data);
56  printf(ANSI_COLOR_RESET);
57 #endif
58 }
59 void robotis_manipulator::log::print(const char* str, STRING color)
60 {
61 #if defined(__OPENCR__)
62  DEBUG.print(str);
63 #else
64  if(color == "RED") printf(ANSI_COLOR_RED);
65  else if(color == "GREEN") printf(ANSI_COLOR_GREEN);
66  else if(color == "YELLOW") printf(ANSI_COLOR_YELLOW);
67  else if(color == "BLUE") printf(ANSI_COLOR_BLUE);
68  else if(color == "MAGENTA") printf(ANSI_COLOR_MAGENTA);
69  else if(color == "CYAN") printf(ANSI_COLOR_CYAN);
70  printf("%s", str);
71  printf(ANSI_COLOR_RESET);
72 #endif
73 }
74 void robotis_manipulator::log::print(const char* str, double data, uint8_t decimal_point, STRING color)
75 {
76 #if defined(__OPENCR__)
77  DEBUG.print(str);
78  DEBUG.print(data, decimal_point);
79 #else
80  if(color == "RED") printf(ANSI_COLOR_RED);
81  else if(color == "GREEN") printf(ANSI_COLOR_GREEN);
82  else if(color == "YELLOW") printf(ANSI_COLOR_YELLOW);
83  else if(color == "BLUE") printf(ANSI_COLOR_BLUE);
84  else if(color == "MAGENTA") printf(ANSI_COLOR_MAGENTA);
85  else if(color == "CYAN") printf(ANSI_COLOR_CYAN);
86  printf("%s %.*lf", str, decimal_point, data);
87  printf(ANSI_COLOR_RESET);
88 #endif
89 }
90 
91 
93 {
94 #if defined(__OPENCR__)
95  DEBUG.println(str);
96 #else
97  if(color == "RED") printf(ANSI_COLOR_RED);
98  else if(color == "GREEN") printf(ANSI_COLOR_GREEN);
99  else if(color == "YELLOW") printf(ANSI_COLOR_YELLOW);
100  else if(color == "BLUE") printf(ANSI_COLOR_BLUE);
101  else if(color == "MAGENTA") printf(ANSI_COLOR_MAGENTA);
102  else if(color == "CYAN") printf(ANSI_COLOR_CYAN);
103  printf("%s\n", str.c_str());
104  printf(ANSI_COLOR_RESET);
105 #endif
106 }
107 void robotis_manipulator::log::println(STRING str, double data, uint8_t decimal_point, STRING color)
108 {
109 #if defined(__OPENCR__)
110  DEBUG.print(str);
111  DEBUG.println(data, decimal_point);
112 #else
113  if(color == "RED") printf(ANSI_COLOR_RED);
114  else if(color == "GREEN") printf(ANSI_COLOR_GREEN);
115  else if(color == "YELLOW") printf(ANSI_COLOR_YELLOW);
116  else if(color == "BLUE") printf(ANSI_COLOR_BLUE);
117  else if(color == "MAGENTA") printf(ANSI_COLOR_MAGENTA);
118  else if(color == "CYAN") printf(ANSI_COLOR_CYAN);
119  printf("%s %.*lf\n", str.c_str(), decimal_point, data);
120  printf(ANSI_COLOR_RESET);
121 #endif
122 }
123 void robotis_manipulator::log::println(const char* str, STRING color)
124 {
125 #if defined(__OPENCR__)
126  DEBUG.println(str);
127 #else
128  if(color == "RED") printf(ANSI_COLOR_RED);
129  else if(color == "GREEN") printf(ANSI_COLOR_GREEN);
130  else if(color == "YELLOW") printf(ANSI_COLOR_YELLOW);
131  else if(color == "BLUE") printf(ANSI_COLOR_BLUE);
132  else if(color == "MAGENTA") printf(ANSI_COLOR_MAGENTA);
133  else if(color == "CYAN") printf(ANSI_COLOR_CYAN);
134  printf("%s\n", str);
135  printf(ANSI_COLOR_RESET);
136 #endif
137 }
138 void robotis_manipulator::log::println(const char* str, double data, uint8_t decimal_point, STRING color)
139 {
140 #if defined(__OPENCR__)
141  DEBUG.print(str);
142  DEBUG.println(data, decimal_point);
143 #else
144  if(color == "RED") printf(ANSI_COLOR_RED);
145  else if(color == "GREEN") printf(ANSI_COLOR_GREEN);
146  else if(color == "YELLOW") printf(ANSI_COLOR_YELLOW);
147  else if(color == "BLUE") printf(ANSI_COLOR_BLUE);
148  else if(color == "MAGENTA") printf(ANSI_COLOR_MAGENTA);
149  else if(color == "CYAN") printf(ANSI_COLOR_CYAN);
150  printf("%s %.*lf\n", str, decimal_point, data);
151  printf(ANSI_COLOR_RESET);
152 #endif
153 }
154 
156 {
157 #if defined(__OPENCR__)
158  DEBUG.print("[INFO] ");
159  DEBUG.println(str);
160 #else
161  printf("[INFO] %s\n", str.c_str());
162 #endif
163 }
164 void robotis_manipulator::log::info(STRING str, double data, uint8_t decimal_point)
165 {
166 #if defined(__OPENCR__)
167  DEBUG.print("[INFO] ");
168  DEBUG.print(str);
169  DEBUG.println(data, decimal_point);
170 #else
171  printf("[INFO] %s %.*lf\n", str.c_str(), decimal_point, data);
172 #endif
173 }
174 void robotis_manipulator::log::info(const char* str)
175 {
176 #if defined(__OPENCR__)
177  DEBUG.print("[INFO] ");
178  DEBUG.println(str);
179 #else
180  printf("[INFO] %s\n", str);
181 #endif
182 }
183 void robotis_manipulator::log::info(const char* str, double data, uint8_t decimal_point)
184 {
185 #if defined(__OPENCR__)
186  DEBUG.print("[INFO] ");
187  DEBUG.print(str);
188  DEBUG.println(data, decimal_point);
189 #else
190  printf("[INFO] %s %.*lf\n", str, decimal_point, data);
191 #endif
192 }
194 {
195 #if defined(__OPENCR__)
196  DEBUG.print("[WARN] ");
197  DEBUG.println(str);
198 #else
199  printf(ANSI_COLOR_YELLOW);
200  printf("[WARN] %s\n", str.c_str());
201  printf(ANSI_COLOR_RESET);
202 #endif
203 }
204 void robotis_manipulator::log::warn(STRING str, double data, uint8_t decimal_point)
205 {
206 #if defined(__OPENCR__)
207  DEBUG.print("[WARN] ");
208  DEBUG.print(str);
209  DEBUG.println(data, decimal_point);
210 #else
211  printf(ANSI_COLOR_YELLOW);
212  printf("[WARN] %s %.*lf\n",str.c_str(), decimal_point, data);
213  printf(ANSI_COLOR_RESET);
214 #endif
215 }
216 void robotis_manipulator::log::warn(const char* str)
217 {
218 #if defined(__OPENCR__)
219  DEBUG.print("[WARN] ");
220  DEBUG.println(str);
221 #else
222  printf(ANSI_COLOR_YELLOW);
223  printf("[WARN] %s\n", str);
224  printf(ANSI_COLOR_RESET);
225 #endif
226 }
227 void robotis_manipulator::log::warn(const char* str, double data, uint8_t decimal_point)
228 {
229 #if defined(__OPENCR__)
230  DEBUG.print("[WARN] ");
231  DEBUG.print(str);
232  DEBUG.println(data, decimal_point);
233 #else
234  printf(ANSI_COLOR_YELLOW);
235  printf("[WARN] %s %.*lf\n", str, decimal_point, data);
236  printf(ANSI_COLOR_RESET);
237 #endif
238 }
240 {
241 #if defined(__OPENCR__)
242  DEBUG.print("[ERROR] ");
243  DEBUG.println(str);
244 #else
245  printf(ANSI_COLOR_RED);
246  printf("[ERROR] %s\n", str.c_str());
247  printf(ANSI_COLOR_RESET);
248 #endif
249 }
250 void robotis_manipulator::log::error(STRING str, double data, uint8_t decimal_point)
251 {
252 #if defined(__OPENCR__)
253  DEBUG.print("[ERROR] ");
254  DEBUG.print(str);
255  DEBUG.println(data, decimal_point);
256 #else
257  printf(ANSI_COLOR_RED);
258  printf("[ERROR] %s %.*lf\n", str.c_str(), decimal_point, data);
259  printf(ANSI_COLOR_RESET);
260 #endif
261 }
262 
263 void robotis_manipulator::log::error(const char* str)
264 {
265 #if defined(__OPENCR__)
266  DEBUG.print("[ERROR] ");
267  DEBUG.println(str);
268 #else
269  printf(ANSI_COLOR_RED);
270  printf("[ERROR] %s\n", str);
271  printf(ANSI_COLOR_RESET);
272 #endif
273 }
274 void robotis_manipulator::log::error(const char* str, double data, uint8_t decimal_point)
275 {
276 #if defined(__OPENCR__)
277  DEBUG.print("[ERROR] ");
278  DEBUG.print(str);
279  DEBUG.println(data, decimal_point);
280 #else
281  printf(ANSI_COLOR_RED);
282  printf("[ERROR] %s %.*lf\n", str, decimal_point, data);
283  printf(ANSI_COLOR_RESET);
284 #endif
285 }
#define ANSI_COLOR_YELLOW
void println(STRING str, STRING color="DEFAULT")
println
#define ANSI_COLOR_RED
#define ANSI_COLOR_GREEN
#define ANSI_COLOR_CYAN
#define ANSI_COLOR_RESET
void print(STRING str, STRING color="DEFAULT")
print
#define ANSI_COLOR_MAGENTA
#define ANSI_COLOR_BLUE
std::string STRING