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
GLint level
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...
Default implementation of OutputHandler. This sends the information to the console.
Definition: console.h:144
void noOutputHandler(void)
This function instructs ompl that no messages should be outputted. Equivalent to useOutputHandler(NUL...
Definition: console.cpp:81
Generic class to handle output from a piece of code.
Definition: console.h:125
const GLfloat * m
Definition: glext.h:6814
LogLevel getLogLevel(void)
Retrieve the current level of logging data. Messages with lower logging levels will not be recorded...
Definition: console.cpp:158
GLsizei const GLchar *const * string
#define CONSOLE_BRIDGE_DEPRECATED
Definition: console.h:51
FILE * file_
The file to save to.
Definition: console.h:171
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
virtual ~OutputHandler(void)
Definition: console.h:133
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
static void CONSOLE_BRIDGE_DEPRECATED console_bridge_deprecated()
Definition: console.h:54
void restorePreviousOutputHandler(void)
Restore the output handler that was previously in use (if any)
Definition: console.cpp:88
Implementation of OutputHandler that saves messages in a file.
Definition: console.h:157
LogLevel
The set of priorities for message logging.
Definition: console.h:109
Message namespace. This contains classes needed to output error messages (or logging) from within the...
Definition: console.h:106
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
void useOutputHandler(OutputHandler *oh)
Specify the instance of the OutputHandler to use. By default, this is OutputHandlerSTD.
Definition: console.cpp:94


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:12