JeVois
1.22
JeVois Smart Embedded Machine Vision Toolkit
|
|
Classes | |
class | jevois::Log< Level > |
Logger class. More... | |
class | jevois::Profiler |
Simple profiler class. More... | |
class | jevois::Timer |
Simple timer class. More... | |
class | jevois::TimerOne |
Simple one-shot timer class. More... | |
class | jevois::Watchdog |
Simple watchdog class. More... | |
Macros | |
#define | LDEBUG(msg) |
Convenience macro for users to print out console or syslog messages, DEBUG level. | |
#define | PLDEBUG(msg) |
Like LDEBUG but appends errno and strerror(errno), to be used when some system call fails. | |
#define | LINFO(msg) |
Convenience macro for users to print out console or syslog messages, INFO level. | |
#define | PLINFO(msg) |
Like LINFO but appends errno and strerror(errno), to be used when some system call fails. | |
#define | LERROR(msg) |
Convenience macro for users to print out console or syslog messages, ERROR level. | |
#define | PLERROR(msg) |
Like LERROR but appends errno and strerror(errno), to be used when some system call fails. | |
#define | LFATAL(msg) |
Convenience macro for users to print out console or syslog messages, FATAL level. | |
#define | PLFATAL(msg) |
Like LDEBUG but appends errno and strerror(errno), to be used when some system call fails. | |
#define | JEVOIS_ASSERT(cond) |
Test whether something is true and issue an LFATAL if not. | |
#define | JEVOIS_TRACE(level) |
Trace object. | |
#define | JEVOIS_TIMED_LOCK(mtx) |
Helper macro to create a timed_lock_guard object. | |
Functions | |
void | jevois::warnAndRethrowException (std::string const &prefix="") |
Convenience function to catch an exception, issue some LERROR (depending on type), and rethrow it. | |
std::string | jevois::warnAndIgnoreException (std::string const &prefix="") |
Convenience function to catch an exception, issue some LERROR (depending on type), and ignore it. | |
void | jevois::warnAndRethrowParamCallbackException (std::string const &descriptor, std::string const &strval) |
Convenience function for parameter callback exceptions. | |
void | jevois::logSetEngine (Engine *e) |
Set an Engine so that all log messages will be forwarded to its serial ports. | |
std::string | jevois::getPythonExceptionString (boost::python::error_already_set &) |
Python exception translation to string so we can print the traceback to our serlog stream. | |
std::string | jevois::getSysInfoCPU () |
Get CPU info: frequency, thermal, load. | |
std::string | jevois::getSysInfoMem () |
Get memory info. | |
std::string | jevois::getSysInfoVersion () |
Get O.S. version info. | |
Variables | |
int | jevois::logLevel = LOG_INFO |
Current log level. | |
int | jevois::traceLevel = 0 |
Current trace level. | |
#define JEVOIS_ASSERT | ( | cond | ) |
#define JEVOIS_TIMED_LOCK | ( | mtx | ) |
#define JEVOIS_TRACE | ( | level | ) |
#define LDEBUG | ( | msg | ) |
Convenience macro for users to print out console or syslog messages, DEBUG level.
This macro is intended to be used with a stream-oriented syntax for everything that is passed as argument to the macro. The syntax is a bit strange at first but you will rapidly get used to it. This allows any datatype that has an operator<< defined to be printed out in a log (contrary to printf-style syntax). For example:
By design, your log message will not be evaluated if the current log level is below (stronger than) the debug level. This means that you should not be afraid of wasting CPU computing messages that will not be output; for example:
will not run the cpu-intensive function if the current log level is LOG_ERR (it will still run one "if" statement to check the current log level). This also means that you should never assume that your log message will be evaluated. For example:
#define LERROR | ( | msg | ) |
Convenience macro for users to print out console or syslog messages, ERROR level.
Usage syntax is the same as for LDEBUG(msg)
#define LFATAL | ( | msg | ) |
Convenience macro for users to print out console or syslog messages, FATAL level.
Convenience macro for users to throw std::runtime_error with convenient message formatting.
Usage syntax is the same as for LDEBUG(msg)
Usage syntax is the same as for LDEBUG(msg). Nothing is added by this function to the user-provided error message. So this is mainly useful for situations where the exception will be caught and a consolidated error message will then be issued via LFATAL() (maybe adding some more context details).
#define LINFO | ( | msg | ) |
Convenience macro for users to print out console or syslog messages, INFO level.
Usage syntax is the same as for LDEBUG(msg)
#define PLDEBUG | ( | msg | ) |
Like LDEBUG but appends errno and strerror(errno), to be used when some system call fails.
Usage syntax is the same as for LDEBUG(msg)
#define PLERROR | ( | msg | ) |
Like LERROR but appends errno and strerror(errno), to be used when some system call fails.
Usage syntax is the same as for LDEBUG(msg)
#define PLFATAL | ( | msg | ) |
Like LDEBUG but appends errno and strerror(errno), to be used when some system call fails.
Usage syntax is the same as for LDEBUG(msg)
#define PLINFO | ( | msg | ) |
Like LINFO but appends errno and strerror(errno), to be used when some system call fails.
Usage syntax is the same as for LDEBUG(msg)
std::string jevois::getPythonExceptionString | ( | boost::python::error_already_set & | ) |
Python exception translation to string so we can print the traceback to our serlog stream.
This code inspired from: https://github.com/abingham/boost_python_exception/tree/master/src/boost_python_exception/auto_translation
You would usually use this from inside a catch(boost::python::error_already_set & e) { ... } block.
Definition at line 154 of file PythonException.C.
Referenced by jevois::PythonWrapper::pythonload(), jevois::GUIhelper::reportAndIgnoreException(), jevois::warnAndIgnoreException(), jevois::warnAndRethrowException(), and jevois::warnAndRethrowParamCallbackException().
std::string jevois::getSysInfoCPU | ( | ) |
Get CPU info: frequency, thermal, load.
Definition at line 24 of file SysInfo.C.
References jevois::getFileString().
Referenced by jevois::GUIhelper::drawSystem(), and jevois::Engine::parseCommand().
std::string jevois::getSysInfoMem | ( | ) |
Get memory info.
Definition at line 66 of file SysInfo.C.
References jevois::getFileString().
Referenced by jevois::GUIhelper::drawSystem(), and jevois::Engine::parseCommand().
std::string jevois::getSysInfoVersion | ( | ) |
Get O.S. version info.
Definition at line 74 of file SysInfo.C.
References jevois::getFileString().
Referenced by jevois::GUIhelper::drawSystem(), and jevois::Engine::parseCommand().
void jevois::logSetEngine | ( | Engine * | e | ) |
Set an Engine so that all log messages will be forwarded to its serial ports.
This function is not intended for general use, Engine uses it internally when users set one of its parameters to enable forwarding of log messages to serial ports.
Definition at line 144 of file Log.C.
Referenced by jevois::logEnd(), jevois::Engine::postInit(), and jevois::Engine::~Engine().
std::string jevois::warnAndIgnoreException | ( | std::string const & | prefix = "" | ) |
Convenience function to catch an exception, issue some LERROR (depending on type), and ignore it.
User code can use this function as follows, to log some trace of the exception that was thrown, and then swallow (ignore) the exception. Use this sparingly, swallowing exceptions often defeats the whole logic of using exceptions in the first place. Example use:
Note that the message that is logged to console is also returned as a string, in case one wants to report it in some other way (e.g., in a GUI or in a video frame using drawErrorImage()).
Definition at line 236 of file Log.C.
References jevois::getPythonExceptionString(), LERROR, and jevois::split().
Referenced by jevois::Camera::abortStream(), jevois::GUIhelper::compileCommand(), jevois::GUIhelper::drawConsole(), jevois::Engine::foreachVideoMapping(), jevois::GUIhelper::headlessDisplay(), jevois::ImGuiBackendMALI::init(), jevois::GPUshader::load(), jevois::Engine::mainLoop(), jevois::PoseSkeletonDefinition::PoseSkeletonDefinition(), jevois::Engine::postInit(), jevois::dnn::Pipeline::process(), jevois::Engine::runScriptFromFile(), jevois::Engine::sendSerial(), jevois::GUIhelper::setparstr(), jevois::CameraDevice::streamOff(), jevois::Camera::streamOff(), jevois::Camera::streamOn(), jevois::Camera::~Camera(), jevois::CameraDevice::~CameraDevice(), jevois::Engine::~Engine(), jevois::Gadget::~Gadget(), jevois::ImGuiBackendMALI::~ImGuiBackendMALI(), and jevois::MovieOutput::~MovieOutput().
void jevois::warnAndRethrowException | ( | std::string const & | prefix = "" | ) |
Convenience function to catch an exception, issue some LERROR (depending on type), and rethrow it.
User code that is not going to swallow exceptions can use this function as follows, to log some trace of the exception that was thrown:
Definition at line 203 of file Log.C.
References jevois::getPythonExceptionString(), LERROR, and jevois::split().
Referenced by jevois::dnn::NetworkNPU::doprocess(), and jevois::dnn::Network::ready().
void jevois::warnAndRethrowParamCallbackException | ( | std::string const & | descriptor, |
std::string const & | strval | ||
) |
Convenience function for parameter callback exceptions.
Used internally by Parameter, likely not so useful to others, included in the jevois namespace to avoid having to pull boost::python into Parameter, which would pull it into pretty much everything and increase compile time a lot.
Definition at line 274 of file Log.C.
References jevois::getPythonExceptionString(), and LERROR.
int jevois::logLevel = LOG_INFO |
Current log level.
The log level is set by changing the value of this global variable. The default value is LOG_INFO.
The possible log values are defined in sys/syslog.h and here we only handle the following with different amounts of messages: LOG_CRIT, LOG_ERR, LOG_INFO, LOG_DEBUG.
int jevois::traceLevel = 0 |
Current trace level.
Higher levels yield more verbosity in tracing. Note that this has effect only if JEVOIS_TRACE_ENABLE is specified as a compile option, and the trace messages are issued at the LDEBUG log level, so JEVOIS_LDEBUG_ENABLE must also be specified at compile time.