8 #ifndef DIAGNOSTIC_CLIENT_LIB_LIB_UTILITY_UTILITY_LOGGER_H
9 #define DIAGNOSTIC_CLIENT_LIB_LIB_UTILITY_UTILITY_LOGGER_H
11 #ifdef ENABLE_DLT_LOGGER
18 #include <string_view>
21 #define UNUSED_PARAM(expr) \
22 do { (void) (expr); } while (0)
47 template<
typename Func>
48 auto LogFatal(
const std::string_view file_name,
int line_no,
const std::string_view func_name, Func &&func) noexcept
50 #ifdef ENABLE_DLT_LOGGER
51 LogDltMessage(DLT_LOG_FATAL, file_name, func_name, line_no, std::forward<Func>(func));
74 template<
typename Func>
75 auto LogError(
const std::string_view file_name,
int line_no,
const std::string_view func_name, Func &&func) noexcept
77 #ifdef ENABLE_DLT_LOGGER
78 LogDltMessage(DLT_LOG_ERROR, file_name, func_name, line_no, std::forward<Func>(func));
100 template<
typename Func>
101 auto LogWarn(
const std::string_view file_name,
int line_no,
const std::string_view func_name, Func &&func) noexcept
103 #ifdef ENABLE_DLT_LOGGER
104 LogDltMessage(DLT_LOG_WARN, file_name, func_name, line_no, std::forward<Func>(func));
126 template<
typename Func>
127 auto LogInfo(
const std::string_view file_name,
int line_no,
const std::string_view func_name, Func &&func) noexcept
129 #ifdef ENABLE_DLT_LOGGER
130 LogDltMessage(DLT_LOG_INFO, file_name, func_name, line_no, std::forward<Func>(func));
152 template<
typename Func>
153 auto LogDebug(
const std::string_view file_name,
int line_no,
const std::string_view func_name, Func &&func) noexcept
155 #ifdef ENABLE_DLT_LOGGER
156 LogDltMessage(DLT_LOG_DEBUG, file_name, func_name, line_no, std::forward<Func>(func));
178 template<
typename Func>
179 auto LogVerbose(
const std::string_view file_name,
int line_no,
const std::string_view func_name, Func &&func) noexcept
181 #ifdef ENABLE_DLT_LOGGER
182 LogDltMessage(DLT_LOG_VERBOSE, file_name, func_name, line_no, std::forward<Func>(func));
197 explicit Logger(std::string_view context_id);
206 Logger(std::string_view app_id, std::string_view context_id);
227 template<
typename Func>
229 Func &&func) noexcept -> std::stringstream {
230 std::stringstream msg{};
232 msg <<
" [" << file_name <<
":" << line_no <<
"]";
249 #ifdef ENABLE_DLT_LOGGER
250 template<
typename Func>
251 void LogDltMessage(DltLogLevelType log_level,
const std::string_view file_name,
const std::string_view func_name,
252 int line_no, Func &&func) {
255 DLT_CSTRING(
CreateLoggingMessage(file_name, func_name, line_no, std::forward<Func>(func)).str().c_str()));
259 #ifdef ENABLE_DLT_LOGGER
Logger class that is used to log Dlt messages from the component.
auto LogDebug(const std::string_view file_name, int line_no, const std::string_view func_name, Func &&func) noexcept -> void
Log debug message.
~Logger()
Destruct an instance of Logger.
Logger(std::string_view context_id)
Construct an instance of Logger.
bool registration_with_app_id_
std::string contxt_
Function to send the messages to dlt infrastructure.
auto LogVerbose(const std::string_view file_name, int line_no, const std::string_view func_name, Func &&func) noexcept -> void
Log verbose message.
auto LogError(const std::string_view file_name, int line_no, const std::string_view func_name, Func &&func) noexcept -> void
Log error message.
auto LogInfo(const std::string_view file_name, int line_no, const std::string_view func_name, Func &&func) noexcept -> void
Log info message.
auto LogFatal(const std::string_view file_name, int line_no, const std::string_view func_name, Func &&func) noexcept -> void
Log fatal message and abort.
auto CreateLoggingMessage(const std::string_view file_name, const std::string_view, int line_no, Func &&func) noexcept -> std::stringstream
Function to create the final logging message.
auto LogWarn(const std::string_view file_name, int line_no, const std::string_view func_name, Func &&func) noexcept -> void
Log warning message.
#define UNUSED_PARAM(expr)