console.h
Go to the documentation of this file.
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2008, Willow Garage, Inc.
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
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the Willow Garage nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34 
35 /* Author: Ryan Luna, Ioan Sucan */
36 
37 #ifndef CONSOLE_BRIDGE_CONSOLE_
38 #define CONSOLE_BRIDGE_CONSOLE_
39 
40 #include <string>
41 
42 #include "exportdecl.h"
43 
44 #ifdef __GNUC__
45 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
46 #define CONSOLE_BRIDGE_DEPRECATED __attribute__ ((deprecated))
47 #elif defined(_MSC_VER)
48 #define CONSOLE_BRIDGE_DEPRECATED __declspec(deprecated)
49 #else
50 #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
51 #define CONSOLE_BRIDGE_DEPRECATED
52 #endif
53 
55 
78 #define CONSOLE_BRIDGE_logError(fmt, ...) \
79  console_bridge::log(__FILE__, __LINE__, console_bridge::CONSOLE_BRIDGE_LOG_ERROR, fmt, ##__VA_ARGS__)
80 
81 #define CONSOLE_BRIDGE_logWarn(fmt, ...) \
82  console_bridge::log(__FILE__, __LINE__, console_bridge::CONSOLE_BRIDGE_LOG_WARN, fmt, ##__VA_ARGS__)
83 
84 #define CONSOLE_BRIDGE_logInform(fmt, ...) \
85  console_bridge::log(__FILE__, __LINE__, console_bridge::CONSOLE_BRIDGE_LOG_INFO, fmt, ##__VA_ARGS__)
86 
87 #define CONSOLE_BRIDGE_logDebug(fmt, ...) \
88  console_bridge::log(__FILE__, __LINE__, console_bridge::CONSOLE_BRIDGE_LOG_DEBUG, fmt, ##__VA_ARGS__)
89 
90 //#define logError(fmt, ...) \
91 // console_bridge::log_deprecated(__FILE__, __LINE__, console_bridge::CONSOLE_BRIDGE_LOG_ERROR, fmt, ##__VA_ARGS__)
92 //
93 //#define logWarn(fmt, ...) \
94 // console_bridge::log_deprecated(__FILE__, __LINE__, console_bridge::CONSOLE_BRIDGE_LOG_WARN, fmt, ##__VA_ARGS__)
95 //
96 //#define logInform(fmt, ...) \
97 // console_bridge::log_deprecated(__FILE__, __LINE__, console_bridge::CONSOLE_BRIDGE_LOG_INFO, fmt, ##__VA_ARGS__)
98 //
99 //#define logDebug(fmt, ...) \
100 // console_bridge::log_deprecated(__FILE__, __LINE__, console_bridge::CONSOLE_BRIDGE_LOG_DEBUG, fmt, ##__VA_ARGS__)
101 
102 
106 namespace console_bridge
107 {
110  {
116  };
117 
126 {
127 public:
128 
130  {
131  }
132 
133  virtual ~OutputHandler(void)
134  {
135  }
136 
139  virtual void log(const std::string &text, LogLevel level, const char *filename, int line) = 0;
140 };
141 
145 {
146 public:
147 
149  {
150  }
151 
152  virtual void log(const std::string &text, LogLevel level, const char *filename, int line);
153 
154 };
155 
158 {
159 public:
160 
162  OutputHandlerFile(const char *filename);
163 
164  virtual ~OutputHandlerFile(void);
165 
166  virtual void log(const std::string &text, LogLevel level, const char *filename, int line);
167 
168 private:
169 
171  FILE *file_;
172 
173 };
174 
176 void noOutputHandler(void);
177 
180 
183 
186 
190 
193 LogLevel getLogLevel(void);
194 
198 void log(const char *file, int line, LogLevel level, const char* m, ...);
199 
203 CONSOLE_BRIDGE_DEPRECATED void log_deprecated(const char *file, int line, LogLevel level, const char* m, ...);
204 }
205 
206 
207 #endif
console_bridge::LogLevel
LogLevel
The set of priorities for message logging.
Definition: console.h:109
console_bridge::CONSOLE_BRIDGE_LOG_INFO
@ CONSOLE_BRIDGE_LOG_INFO
Definition: console.h:112
console_bridge::CONSOLE_BRIDGE_LOG_DEBUG
@ CONSOLE_BRIDGE_LOG_DEBUG
Definition: console.h:111
console_bridge::log_deprecated
CONSOLE_BRIDGE_DEPRECATED void log_deprecated(const char *file, int line, LogLevel level, const char *m,...)
Root level logging function. This should not be invoked directly, but rather used via a logging macro...
Definition: console.cpp:106
console_bridge
Message namespace. This contains classes needed to output error messages (or logging) from within the...
Definition: console.h:106
console_bridge::CONSOLE_BRIDGE_LOG_WARN
@ CONSOLE_BRIDGE_LOG_WARN
Definition: console.h:113
console_bridge::OutputHandlerSTD::OutputHandlerSTD
OutputHandlerSTD(void)
Definition: console.h:148
console_bridge::log
void log(const char *file, int line, LogLevel level, const char *m,...)
Root level logging function. This should not be invoked directly, but rather used via a logging macro...
Definition: console.cpp:132
console_bridge::CONSOLE_BRIDGE_LOG_NONE
@ CONSOLE_BRIDGE_LOG_NONE
Definition: console.h:115
string
GLsizei const GLchar *const * string
Definition: glad/glad/glad.h:2861
console_bridge::OutputHandler::OutputHandler
OutputHandler(void)
Definition: console.h:129
console_bridge::CONSOLE_BRIDGE_LOG_ERROR
@ CONSOLE_BRIDGE_LOG_ERROR
Definition: console.h:114
console_bridge::OutputHandlerFile::file_
FILE * file_
The file to save to.
Definition: console.h:171
console_bridge::OutputHandlerSTD
Default implementation of OutputHandler. This sends the information to the console.
Definition: console.h:144
console_bridge::OutputHandlerSTD::log
virtual void log(const std::string &text, LogLevel level, const char *filename, int line)
log a message to the output handler with the given text and logging level from a specific file and li...
Definition: console.cpp:166
m
std::mutex m
Definition: test-waiting-on.cpp:126
console_bridge::OutputHandlerFile::~OutputHandlerFile
virtual ~OutputHandlerFile(void)
Definition: console.cpp:193
console_bridge::restorePreviousOutputHandler
void restorePreviousOutputHandler(void)
Restore the output handler that was previously in use (if any)
Definition: console.cpp:88
console_bridge::OutputHandler::log
virtual void log(const std::string &text, LogLevel level, const char *filename, int line)=0
log a message to the output handler with the given text and logging level from a specific file and li...
CONSOLE_BRIDGE_DEPRECATED
#define CONSOLE_BRIDGE_DEPRECATED
Definition: console.h:51
console_bridge::getOutputHandler
OutputHandler * getOutputHandler(void)
Get the instance of the OutputHandler currently used. This is NULL in case there is no output handler...
Definition: console.cpp:101
console_bridge_deprecated
static void CONSOLE_BRIDGE_DEPRECATED console_bridge_deprecated()
Definition: console.h:54
level
GLint level
Definition: glad/glad/glad.h:1412
console_bridge::OutputHandlerFile
Implementation of OutputHandler that saves messages in a file.
Definition: console.h:157
console_bridge::useOutputHandler
void useOutputHandler(OutputHandler *oh)
Specify the instance of the OutputHandler to use. By default, this is OutputHandlerSTD.
Definition: console.cpp:94
console_bridge::setLogLevel
void setLogLevel(LogLevel level)
Set the minimum level of logging data to output. Messages with lower logging levels will not be recor...
Definition: console.cpp:152
python-tutorial-1-depth.line
string line
Definition: python-tutorial-1-depth.py:38
console_bridge::OutputHandler::~OutputHandler
virtual ~OutputHandler(void)
Definition: console.h:133
test-projection-from-recording.filename
filename
Definition: test-projection-from-recording.py:15
console_bridge::OutputHandler
Generic class to handle output from a piece of code.
Definition: console.h:125
console_bridge::OutputHandlerFile::OutputHandlerFile
OutputHandlerFile(const char *filename)
The name of the file in which to save the message data.
Definition: console.cpp:181
exportdecl.h
console_bridge::getLogLevel
LogLevel getLogLevel(void)
Retrieve the current level of logging data. Messages with lower logging levels will not be recorded.
Definition: console.cpp:158
console_bridge::noOutputHandler
void noOutputHandler(void)
This function instructs ompl that no messages should be outputted. Equivalent to useOutputHandler(NUL...
Definition: console.cpp:81
console_bridge::OutputHandlerFile::log
virtual void log(const std::string &text, LogLevel level, const char *filename, int line)
log a message to the output handler with the given text and logging level from a specific file and li...
Definition: console.cpp:200


librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Fri Aug 2 2024 08:30:01