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
273 inline TraceObject(
int level,
char const * file,
char const * func) :
274 itsLevel(level), itsFile(file), itsFunc(func)
278 inline ~TraceObject()
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)
308 class timed_lock_guard
312 explicit timed_lock_guard(std::timed_mutex & mtx,
char const * file,
char const * func);
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)) == \
333std::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)
Log< Level > & operator<<(T const &out_item)
Overloaded stream input operator for any type that has operator<< defined for ostream.
~Log()
Close the Log, outputting the aggregated message.
int logLevel
Current log level.
int traceLevel
Current trace level.
void logSetEngine(Engine *e)
Set an Engine so that all log messages will be forwarded to its serial ports.
std::string warnAndIgnoreException(std::string const &prefix="")
Convenience function to catch an exception, issue some LERROR (depending on type),...
void warnAndRethrowParamCallbackException(std::string const &descriptor, std::string const &strval)
Convenience function for parameter callback exceptions.
void warnAndRethrowException(std::string const &prefix="")
Convenience function to catch an exception, issue some LERROR (depending on type),...
Main namespace for all JeVois classes and functions.
void drawErrorImage(std::string const &errmsg, RawImage &videoerrimg)
Display an error message into a RawImage.
void logEnd()
Terminate log service.