5 #ifndef UAVCAN_PROTOCOL_LOGGER_HPP_INCLUDED
6 #define UAVCAN_PROTOCOL_LOGGER_HPP_INCLUDED
10 #include <uavcan/protocol/debug/LogMessage.hpp>
15 #if !defined(UAVCAN_CPP_VERSION) || !defined(UAVCAN_CPP11)
16 # error UAVCAN_CPP_VERSION
44 virtual void log(
const protocol::debug::LogMessage& message) = 0;
70 enum { DefaultTxTimeoutMs = 2000 };
99 const int res = logmsg_pub_.
init(priority);
118 int log(
const protocol::debug::LogMessage& message)
121 if (message.level.value >= getExternalSinkLevel())
123 external_sink_->
log(message);
125 if (message.level.value >= level_)
174 #if UAVCAN_CPP_VERSION >= UAVCAN_CPP11
176 template <
typename... Args>
179 template <
typename... Args>
182 return log(protocol::debug::LogLevel::DEBUG, source,
format,
args...);
185 template <
typename... Args>
188 return log(protocol::debug::LogLevel::INFO, source,
format,
args...);
191 template <
typename... Args>
194 return log(protocol::debug::LogLevel::WARNING, source,
format,
args...);
197 template <
typename... Args>
207 #if UAVCAN_EXCEPTIONS
211 if (
level >= level_ ||
level >= getExternalSinkLevel())
213 msg_buf_.level.value =
level;
214 msg_buf_.source = source;
215 msg_buf_.text = text;
216 return log(msg_buf_);
220 #if UAVCAN_EXCEPTIONS
230 return log(protocol::debug::LogLevel::DEBUG, source, text);
235 return log(protocol::debug::LogLevel::INFO, source, text);
240 return log(protocol::debug::LogLevel::WARNING, source, text);
254 #if UAVCAN_CPP_VERSION >= UAVCAN_CPP11
256 template <
typename... Args>
259 #if UAVCAN_EXCEPTIONS
263 if (
level >= level_ ||
level >= getExternalSinkLevel())
265 msg_buf_.level.value =
level;
266 msg_buf_.source = source;
267 msg_buf_.text.clear();
270 return log(msg_buf_);
274 #if UAVCAN_EXCEPTIONS
286 #endif // UAVCAN_PROTOCOL_LOGGER_HPP_INCLUDED