Go to the documentation of this file.
68 #ifndef AP_SECURITY_SDK_LOGGER_H
69 #define AP_SECURITY_SDK_LOGGER_H
71 #include <logger-config.h>
76 namespace VirgilIoTKit {
98 #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
101 #define VS_LOG_GET_LOGLEVEL(LOGLEV_VARIABLE) (LOGLEV_VARIABLE) = vs_logger_get_loglev()
103 #define VS_LOG_IS_LOGLEVEL(LOGLEV_VALUE) vs_logger_is_loglev(LOGLEV_VALUE)
105 #define VS_LOG_SET_LOGLEVEL(LOGLEV_VALUE) vs_logger_set_loglev(LOGLEV_VALUE)
108 #if VS_IOT_LOGGER_USE_LIBRARY
112 #include <stdlib-config.h>
122 #define VS_LOG(LGLVL, FRMT, ...) vs_logger_message((LGLVL), __FILENAME__, __LINE__, (FRMT), ##__VA_ARGS__)
133 #define VS_LOG_HEX(LGLVL, PREFIX, BUF, SIZE) \
134 vs_logger_message_hex((LGLVL), __FILENAME__, __LINE__, (PREFIX), (BUF), (SIZE))
149 #define VS_LOG_MAKE_LEVEL(LEVEL) VirgilIoTKit::LEVEL
151 #define VS_LOG_MAKE_LEVEL(LEVEL) LEVEL
155 #define VS_LOG_INFO(FRMT, ...) \
156 vs_logger_message(VS_LOG_MAKE_LEVEL(VS_LOGLEV_INFO), __FILENAME__, __LINE__, (FRMT), ##__VA_ARGS__)
158 #define VS_LOG_FATAL(FRMT, ...) \
159 vs_logger_message(VS_LOG_MAKE_LEVEL(VS_LOGLEV_FATAL), __FILENAME__, __LINE__, (FRMT), ##__VA_ARGS__)
161 #define VS_LOG_ALERT(FRMT, ...) \
162 vs_logger_message(VS_LOG_MAKE_LEVEL(VS_LOGLEV_ALERT), __FILENAME__, __LINE__, (FRMT), ##__VA_ARGS__)
164 #define VS_LOG_CRITICAL(FRMT, ...) \
165 vs_logger_message(VS_LOG_MAKE_LEVEL(VS_LOGLEV_CRITICAL), __FILENAME__, __LINE__, (FRMT), ##__VA_ARGS__)
167 #define VS_LOG_ERROR(FRMT, ...) \
168 vs_logger_message(VS_LOG_MAKE_LEVEL(VS_LOGLEV_ERROR), __FILENAME__, __LINE__, (FRMT), ##__VA_ARGS__)
170 #define VS_LOG_WARNING(FRMT, ...) \
171 vs_logger_message(VS_LOG_MAKE_LEVEL(VS_LOGLEV_WARNING), __FILENAME__, __LINE__, (FRMT), ##__VA_ARGS__)
173 #define VS_LOG_NOTICE(FRMT, ...) \
174 vs_logger_message(VS_LOG_MAKE_LEVEL(VS_LOGLEV_NOTICE), __FILENAME__, __LINE__, (FRMT), ##__VA_ARGS__)
176 #define VS_LOG_TRACE(FRMT, ...) \
177 vs_logger_message(VS_LOG_MAKE_LEVEL(VS_LOGLEV_TRACE), __FILENAME__, __LINE__, (FRMT), ##__VA_ARGS__)
179 #define VS_LOG_DEBUG(FRMT, ...) \
180 vs_logger_message(VS_LOG_MAKE_LEVEL(VS_LOGLEV_DEBUG), __FILENAME__, __LINE__, (FRMT), ##__VA_ARGS__)
261 const char *cur_filename,
264 const void *data_buf,
265 const uint16_t data_size);
267 #elif VS_IOT_LOGGER_USE_LIBRARY != 1 && defined(VS_IOT_LOGGER_FUNCTION)
269 #define vs_logger_last_result() true
270 #define vs_logger_init(log_level) (void)log_level;
271 #define vs_logger_set_loglev(log_level) (void)log_level;
272 #define vs_logger_get_loglev() VS_LOGLEV_NO_LOGGER
273 #define vs_logger_is_loglev(level) ((level) == VS_LOGLEV_NO_LOGGER)
275 #define vs_logger_message_hex(level, cur_filename, line_num, prefix, data_buf, data_size) \
278 (void)cur_filename; \
285 #define vs_logger_message(level, cur_filename, line_num, log_format, ...) \
288 (void)cur_filename; \
290 VS_IOT_LOGGER_FUNCTION((log_format), ##__VA_ARGS__); \
291 VS_IOT_LOGGER_FUNCTION(VS_IOT_LOGGER_EOL); \
294 #else // VS_IOT_LOGGER_USE_LIBRARY != 1 && !defined(VS_IOT_LOGGER_FUNCTION)
296 #include "macro_va_args.h"
298 #define vs_logger_last_result() true
299 #define vs_logger_init(log_level) (void)log_level;
300 #define vs_logger_set_loglev(log_level) (void)log_level;
301 #define vs_logger_get_loglev() VS_LOGLEV_NO_LOGGER
302 #define vs_logger_is_loglev(level) ((level) == VS_LOGLEV_NO_LOGGER)
303 #define vs_log_thread_descriptor() (true)
305 #define VS_IOT_LOGGER_VOID(a) (void)a;
307 #define VS_LOG(LGLVL, FRMT, ...) VS_IOT_MAP(VS_IOT_LOGGER_VOID, FRMT, ##__VA_ARGS__)
308 #define VS_LOG_HEX(LGLVL, PREFIX, BUF, SIZE) VS_IOT_MAP(VS_IOT_LOGGER_VOID, PREFIX, BUF, SIZE)
309 #define VS_LOG_INFO(FRMT, ...) VS_IOT_MAP(VS_IOT_LOGGER_VOID, FRMT, ##__VA_ARGS__)
310 #define VS_LOG_FATAL(FRMT, ...) VS_IOT_MAP(VS_IOT_LOGGER_VOID, FRMT, ##__VA_ARGS__)
311 #define VS_LOG_ALERT(FRMT, ...) VS_IOT_MAP(VS_IOT_LOGGER_VOID, FRMT, ##__VA_ARGS__)
312 #define VS_LOG_CRITICAL(FRMT, ...) VS_IOT_MAP(VS_IOT_LOGGER_VOID, FRMT, ##__VA_ARGS__)
313 #define VS_LOG_ERROR(FRMT, ...) VS_IOT_MAP(VS_IOT_LOGGER_VOID, FRMT, ##__VA_ARGS__)
314 #define VS_LOG_WARNING(FRMT, ...) VS_IOT_MAP(VS_IOT_LOGGER_VOID, FRMT, ##__VA_ARGS__)
315 #define VS_LOG_NOTICE(FRMT, ...) VS_IOT_MAP(VS_IOT_LOGGER_VOID, FRMT, ##__VA_ARGS__)
316 #define VS_LOG_TRACE(FRMT, ...) VS_IOT_MAP(VS_IOT_LOGGER_VOID, FRMT, ##__VA_ARGS__)
317 #define VS_LOG_DEBUG(FRMT, ...) VS_IOT_MAP(VS_IOT_LOGGER_VOID, FRMT, ##__VA_ARGS__)
319 #endif // VS_IOT_LOGGER_USE_LIBRARY
326 #endif // AP_SECURITY_SDK_LOGGER_H
@ VS_LOGLEV_WARNING
Warning messages.
Definition: logger.h:91
@ VS_LOGLEV_DEBUG
Debug messages.
Definition: logger.h:95
@ VS_LOGLEV_ALERT
Alert messages.
Definition: logger.h:88
void vs_logger_message(vs_log_level_t level, const char *cur_filename, uint32_t line_num, const char *log_format,...)
Log text message.
vs_log_level_t vs_logger_get_loglev(void)
Get current logging level.
@ VS_LOGLEV_FATAL
Fatal messages.
Definition: logger.h:87
vs_log_level_t vs_logger_set_loglev(vs_log_level_t new_level)
Set current logging level.
@ VS_LOGLEV_TRACE
Trace messages.
Definition: logger.h:93
vs_log_level_t
Logging level.
Definition: logger.h:82
void vs_logger_init(vs_log_level_t log_level)
Initialize logging level.
@ VS_LOGLEV_ERROR
Error messages.
Definition: logger.h:90
bool vs_logger_last_result(void)
Last result.
bool vs_log_thread_descriptor(const char *description)
Set current thread description.
void vs_logger_message_hex(vs_log_level_t level, const char *cur_filename, uint32_t line_num, const char *prefix, const void *data_buf, const uint16_t data_size)
Log HEX buffer.
@ VS_LOGLEV_NOTICE
Notifications.
Definition: logger.h:92
@ VS_LOGLEV_CRITICAL
Critical messages.
Definition: logger.h:89
@ VS_LOGLEV_NO_LOGGER
Logging is disabled.
Definition: logger.h:84
@ VS_LOGLEV_UNKNOWN
Invalid logging level.
Definition: logger.h:83
bool vs_logger_is_loglev(vs_log_level_t level)
Check that specified logging level is enabled.
@ VS_LOGLEV_INFO
Information messages.
Definition: logger.h:86