JeVois
1.20
JeVois Smart Embedded Machine Vision Toolkit
|
Share this page: |
|
|
|
|
|
|
Go to the documentation of this file.
20 #include <sys/syslog.h>
60 Log(
char const * fullFileName,
char const * functionName, std::string * outstr =
nullptr);
66 template <
class T>
inline
76 std::ostringstream itsLogStream;
77 std::string * itsOutStr;
115 void drawErrorImage(std::string
const & errmsg, RawImage & videoerrimg);
130 #ifdef JEVOIS_LDEBUG_ENABLE
173 #define LDEBUG(msg) do { if (jevois::logLevel >= LOG_DEBUG) \
174 jevois::Log<LOG_DEBUG>(__FILE__, __FUNCTION__) << msg; } while (false)
181 #define PLDEBUG(msg) do { if (jevois::logLevel >= LOG_DEBUG) \
182 jevois::Log<LOG_DEBUG>(__FILE__, __FUNCTION__) << msg << " [" << errno << "](" << strerror(errno) << ')'; } \
185 #define LDEBUG(msg) do { } while (false)
186 #define PLDEBUG(msg) do { } while (false)
194 #define LINFO(msg) do { if (jevois::logLevel >= LOG_INFO) jevois::Log<LOG_INFO>(__FILE__, __FUNCTION__) << msg; } \
202 #define PLINFO(msg) do { if (jevois::logLevel >= LOG_INFO) \
203 jevois::Log<LOG_INFO>(__FILE__, __FUNCTION__) << msg << " [" << errno << "](" << strerror(errno) << ')'; } \
211 #define LERROR(msg) do { if (jevois::logLevel >= LOG_ERR) jevois::Log<LOG_ERR>(__FILE__, __FUNCTION__) << msg; } \
219 #define PLERROR(msg) do { if (jevois::logLevel >= LOG_ERR) \
220 jevois::Log<LOG_ERR>(__FILE__, __FUNCTION__) << msg << " [" << errno << "](" << strerror(errno) << ')'; } \
230 #define LFATAL(msg) do { std::string str; { jevois::Log<LOG_CRIT>(__FILE__, __FUNCTION__, &str) << msg; } \
231 throw std::runtime_error(str); } while (false)
239 #define PLFATAL(msg) do { std::string str; { jevois::Log<LOG_CRIT>(__FILE__, __FUNCTION__, &str) \
240 << msg << " [" << errno << "](" << strerror(errno) << ')'; } \
241 throw std::runtime_error(str); } while (false)
251 #define LTHROW(msg) do { std::string str; { jevois::Log<LOG_ALERT>(nullptr, nullptr, &str) << msg; } \
252 throw std::runtime_error(str); } while (false)
257 #define JEVOIS_ASSERT(cond) do { if (cond) { } else \
258 { std::string str; { jevois::Log<LOG_CRIT>(__FILE__, __FUNCTION__, &str) << "Assertion failed: " #cond; } \
259 throw std::runtime_error(str); } } while (false)
262 #ifdef JEVOIS_TRACE_ENABLE
274 itsLevel(level), itsFile(
file), itsFunc(func)
283 char const *
const itsFile;
284 char const *
const itsFunc;
296 #define JEVOIS_TRACE(level) jevois::trace::TraceObject __jevois_trace_reserved(level, __FILE__, __FUNCTION__)
298 #define JEVOIS_TRACE(level) do { } while (0)
318 std::timed_mutex & itsMutex;
328 #define JEVOIS_TIMED_LOCK(mtx) jevois::timed_lock_guard __jevois_timed_lock_guard_reserved(mtx, __FILE__, __FUNCTION__)
332 #define JEVOIS_WAIT_FOR_FUTURE(f) do { if (f.valid() && f.wait_for(std::chrono::seconds(2)) == \
333 std::future_status::timeout) LFATAL("Timeout waiting for future " #f); } while(false)
336 #define JEVOIS_WAIT_GET_FUTURE(f) do { if (f.valid()) { \
337 if (f.wait_for(std::chrono::seconds(5)) == std::future_status::timeout) LERROR("Timeout waiting for future " #f); \
338 try { f.get(); } catch (...) { jevois::warnAndIgnoreException(); } } } while(false)
void warnAndRethrowException(std::string const &prefix="")
Convenience function to catch an exception, issue some LERROR (depending on type),...
~timed_lock_guard()
Destructor, unlocks the mutex.
void drawErrorImage(std::string const &errmsg, RawImage &videoerrimg)
Display an error message into a RawImage.
Helper class for tracing, issues one message on construction, and another on destruction.
~Log()
Close the Log, outputting the aggregated message.
timed_lock_guard(std::timed_mutex &mtx, char const *file, char const *func)
Constructor, locks the mutex or throw if it cannot be locked before timeout.
int traceLevel
Current trace level.
Data collection mode RAW means that the latest available raw data is returned each time hence timing may not be very accurate depending on how regularly grate into a FIFO and and accumulates resulting output data into the IMU s internal FIFO buffer at a fixed rate This parameter can only be set in a module s params cfg file
void logSetEngine(Engine *e)
Set an Engine so that all log messages will be forwarded to its serial ports.
void warnAndRethrowParamCallbackException(std::string const &descriptor, std::string const &strval)
Convenience function for parameter callback exceptions.
std::string warnAndIgnoreException(std::string const &prefix="")
Convenience function to catch an exception, issue some LERROR (depending on type),...
Log< Level > & operator<<(T const &out_item)
Overloaded stream input operator for any type that has operator<< defined for ostream.
int logLevel
Current log level.
~TraceObject()
Destructor, logs "file:function Exit".
Log(char const *fullFileName, char const *functionName, std::string *outstr=nullptr)
Construct a new Log, adding a prefix to the log stream.
void logEnd()
Terminate log service.
Acquire a lock object on a std::timed_mutex, or LFATAL after 1 second of waiting.
TraceObject(int level, char const *file, char const *func)
Constructor, logs "file:function Enter".