knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
Logger.h File Reference
#include <spdlog/spdlog.h>
#include <spdlog/fmt/ostr.h>
#include <boost/property_tree/ptree.hpp>
Include dependency graph for Logger.h:

Go to the source code of this file.

Classes

class  knowrob::Logger
 

Namespaces

 knowrob
 

Macros

#define SPDLOG_ACTIVE_LEVEL   SPDLOG_LEVEL_TRACE
 
#define KB_TRACE   SPDLOG_TRACE
 
#define KB_DEBUG   SPDLOG_DEBUG
 
#define KB_INFO   SPDLOG_INFO
 
#define KB_WARN   SPDLOG_WARN
 
#define KB_ERROR   SPDLOG_ERROR
 
#define KB_CRITICAL   SPDLOG_CRITICAL
 
#define KB_LOGGER_CALL(file, line, level, ...)    spdlog::default_logger_raw()->log(spdlog::source_loc{file, line, SPDLOG_FUNCTION}, level, __VA_ARGS__)
 
#define KB_TRACE1(file, line, ...)   KB_LOGGER_CALL(file, line, spdlog::level::trace, __VA_ARGS__)
 
#define KB_DEBUG1(file, line, ...)   KB_LOGGER_CALL(file, line, spdlog::level::debug, __VA_ARGS__)
 
#define KB_INFO1(file, line, ...)   KB_LOGGER_CALL(file, line, spdlog::level::info, __VA_ARGS__)
 
#define KB_WARN1(file, line, ...)   KB_LOGGER_CALL(file, line, spdlog::level::warn, __VA_ARGS__)
 
#define KB_ERROR1(file, line, ...)   KB_LOGGER_CALL(file, line, spdlog::level::err, __VA_ARGS__)
 
#define KB_CRITICAL1(file, line, ...)   KB_LOGGER_CALL(file, line, spdlog::level::critical, __VA_ARGS__)
 
#define KB_LOGGED_TRY_CATCH(name, type, goal)
 
#define KB_LOGGED_TRY_EXCEPT(name, type, goal, except)
 

Macro Definition Documentation

◆ KB_CRITICAL

#define KB_CRITICAL   SPDLOG_CRITICAL

Definition at line 29 of file Logger.h.

◆ KB_CRITICAL1

#define KB_CRITICAL1 (   file,
  line,
  ... 
)    KB_LOGGER_CALL(file, line, spdlog::level::critical, __VA_ARGS__)

Definition at line 65 of file Logger.h.

◆ KB_DEBUG

#define KB_DEBUG   SPDLOG_DEBUG

Definition at line 25 of file Logger.h.

◆ KB_DEBUG1

#define KB_DEBUG1 (   file,
  line,
  ... 
)    KB_LOGGER_CALL(file, line, spdlog::level::debug, __VA_ARGS__)

Definition at line 41 of file Logger.h.

◆ KB_ERROR

#define KB_ERROR   SPDLOG_ERROR

Definition at line 28 of file Logger.h.

◆ KB_ERROR1

#define KB_ERROR1 (   file,
  line,
  ... 
)    KB_LOGGER_CALL(file, line, spdlog::level::err, __VA_ARGS__)

Definition at line 59 of file Logger.h.

◆ KB_INFO

#define KB_INFO   SPDLOG_INFO

Definition at line 26 of file Logger.h.

◆ KB_INFO1

#define KB_INFO1 (   file,
  line,
  ... 
)    KB_LOGGER_CALL(file, line, spdlog::level::info, __VA_ARGS__)

Definition at line 47 of file Logger.h.

◆ KB_LOGGED_TRY_CATCH

#define KB_LOGGED_TRY_CATCH (   name,
  type,
  goal 
)
Value:
do { \
try { goal } \
catch (const boost::python::error_already_set&) \
{ LOG_KNOWROB_ERROR(PythonError(), Logger::formatGenericFailure(name,type)); } \
catch (KnowRobError &e) \
{ LOG_KNOWROB_ERROR(e, Logger::formatGenericFailure(name,type)); } \
catch (std::exception &e) \
{ KB_ERROR("{}. {}", Logger::formatGenericFailure(name,type), e.what()); } \
catch (...) \
{ KB_ERROR("{}. Unknown failure!", Logger::formatGenericFailure(name,type)); } \
} while(0)
#define LOG_KNOWROB_ERROR(err, msg,...)
Definition: KnowRobError.h:79
#define KB_ERROR
Definition: Logger.h:28
const IRIAtomPtr type
Definition: rdf.h:15

Catch any exception that goal may throw and log it as an error.

Definition at line 142 of file Logger.h.

◆ KB_LOGGED_TRY_EXCEPT

#define KB_LOGGED_TRY_EXCEPT (   name,
  type,
  goal,
  except 
)
Value:
do { \
try { goal } \
catch (const boost::python::error_already_set&) \
{ LOG_KNOWROB_ERROR(PythonError(), Logger::formatGenericFailure(name,type)); except } \
catch (KnowRobError &e) \
{ LOG_KNOWROB_ERROR(e, Logger::formatGenericFailure(name,type)); except } \
catch (std::exception &e) \
{ KB_ERROR("{}: {}", Logger::formatGenericFailure(name,type), e.what()); except } \
catch (...) \
{ KB_ERROR("{}: unknown failure.", Logger::formatGenericFailure(name,type)); except } \
} while(0)

Catch any exception that goal may throw and log it as an error.

Definition at line 157 of file Logger.h.

◆ KB_LOGGER_CALL

#define KB_LOGGER_CALL (   file,
  line,
  level,
  ... 
)     spdlog::default_logger_raw()->log(spdlog::source_loc{file, line, SPDLOG_FUNCTION}, level, __VA_ARGS__)

Definition at line 31 of file Logger.h.

◆ KB_TRACE

#define KB_TRACE   SPDLOG_TRACE

Definition at line 24 of file Logger.h.

◆ KB_TRACE1

#define KB_TRACE1 (   file,
  line,
  ... 
)    KB_LOGGER_CALL(file, line, spdlog::level::trace, __VA_ARGS__)

Definition at line 35 of file Logger.h.

◆ KB_WARN

#define KB_WARN   SPDLOG_WARN

Definition at line 27 of file Logger.h.

◆ KB_WARN1

#define KB_WARN1 (   file,
  line,
  ... 
)    KB_LOGGER_CALL(file, line, spdlog::level::warn, __VA_ARGS__)

Definition at line 53 of file Logger.h.

◆ SPDLOG_ACTIVE_LEVEL

#define SPDLOG_ACTIVE_LEVEL   SPDLOG_LEVEL_TRACE

Definition at line 14 of file Logger.h.