DJI Onboard SDK  4.0
dji_log.hpp
Go to the documentation of this file.
1 
30 #ifndef LOG_H
31 #define LOG_H
32 
33 #include "dji_singleton.hpp"
34 #include "dji_platform.hpp"
35 
36 
37 #ifdef WIN32
38 #define __func__ __FUNCTION__
39 #endif // WIN32
40 
41 #define DLOG(_title_) \
42  DJI::OSDK::Log::instance() \
43  .title((_title_), #_title_, __func__, __LINE__) \
44  .print
45 
46 #define DLOG_PRIVATE(_title_) \
47  DJI::OSDK::Log::instance() \
48  .title((_title_), #_title_) \
49  .print
50 
51 #define STATUS DJI::OSDK::Log::instance().getStatusLogState()
52 #define ERRORLOG DJI::OSDK::Log::instance().getErrorLogState()
53 #define DEBUG DJI::OSDK::Log::instance().getDebugLogState()
54 
59 #define DSTATUS DLOG(STATUS)
60 #define DSTATUS_PRIVATE DLOG_PRIVATE(STATUS)
61 
66 #define DERROR DLOG(ERRORLOG)
67 #define DERROR_PRIVATE DLOG_PRIVATE(ERRORLOG)
68 
73 #define DDEBUG DLOG(DEBUG)
74 #define DDEBUG_PRIVATE DLOG_PRIVATE(DEBUG)
75 
76 namespace DJI
77 {
78 namespace OSDK
79 {
80 
82 
89 class Log : public Singleton<Log>
90 {
91 public:
92  Log(Mutex* m = 0);
93  ~Log();
94 
97  Log& title(int level, const char* prefix, const char* func, int line);
98 
101  Log& title(int level, const char* prefix);
102 
103  Log& print();
104 
109  void enableStatusLogging();
110 
115  void disableStatusLogging();
116 
121  void enableDebugLogging();
122 
127  void disableDebugLogging();
128 
133  void enableErrorLogging();
134 
139  void disableErrorLogging();
140 
141  // Retrieve logging switches - used for global macros
142  bool getStatusLogState();
143  bool getDebugLogState();
144  bool getErrorLogState();
145 
146  virtual Log& print(const char* fmt, ...);
147 
148  Log& operator<<(bool val);
149  Log& operator<<(short val);
150  Log& operator<<(uint16_t val);
151  Log& operator<<(int val);
152  Log& operator<<(uint32_t val);
153  Log& operator<<(long val);
154  Log& operator<<(unsigned long val);
155  Log& operator<<(long long val);
156  Log& operator<<(unsigned long long val);
157  Log& operator<<(float val);
158  Log& operator<<(double val);
159  Log& operator<<(long double val);
160  Log& operator<<(void* val);
161  Log& operator<<(char c);
162  Log& operator<<(uint8_t c);
163  Log& operator<<(int8_t c);
164  Log& operator<<(const char* str);
165 
166 private:
167  Mutex* mutex;
168  bool vaild;
169  bool initFlag;
170 
171  // @todo implement
172  typedef enum NUMBER_STYLE {
173  STYLE_DEC,
174  STYLE_HEX,
175  STYLE_BIN,
176  STYLE_OCT
177  } NUMBER_STYLE;
178 
179  // Some default printing mechanism toggles
180  bool enable_status;
181  bool enable_debug;
182  bool enable_error;
183 
184  static const bool release = false;
185 };
186 
187 } // namespace OSDK
188 } // namespace DJI
189 
190 #endif // LOG_H
void disableDebugLogging()
Disable logging of status messages called through DDEBUG macro.
void enableStatusLogging()
Enable logging of status messages called through DSTATUS macro.
Logger for DJI OSDK supporting different logging channels.
Definition: dji_log.hpp:89
Vehicle API for DJI onboardSDK library.
Log & title(int level, const char *prefix, const char *func, int line)
Singleton Template Class implementation for use with the DJI OSDK.
void enableDebugLogging()
Enable logging of status messages called through DDEBUG macro.
void enableErrorLogging()
Enable logging of status messages called through DERROR macro.
void disableStatusLogging()
Disable logging of status messages called through DSTATUS macro.
handle array of characters
Definition: commondatarangehandler.h:14
void disableErrorLogging()
Disable logging of status messages called through DERROR macro.
Definition: dji_thread_manager.hpp:41