acc_integration_log.h
Go to the documentation of this file.
1 // Copyright (c) Acconeer AB, 2016-2021
2 // All rights reserved
3
4 #ifndef ACC_INTEGRATION_LOG_H_
5 #define ACC_INTEGRATION_LOG_H_
6
7 #include "acc_definitions_common.h"
8 #include "acc_integration.h"
9
10 #ifdef ACC_LOG_RSS_H_
11 #error "acc_integration_log.h and acc_log_rss.h cannot coexist"
12 #endif
13
14 #define ACC_LOG(level, ...) acc_integration_log(level, MODULE, __VA_ARGS__)
15
16 #define ACC_LOG_ERROR(...) ACC_LOG(ACC_LOG_LEVEL_ERROR, __VA_ARGS__)
17 #define ACC_LOG_WARNING(...) ACC_LOG(ACC_LOG_LEVEL_WARNING, __VA_ARGS__)
18 #define ACC_LOG_INFO(...) ACC_LOG(ACC_LOG_LEVEL_INFO, __VA_ARGS__)
19 #define ACC_LOG_VERBOSE(...) ACC_LOG(ACC_LOG_LEVEL_VERBOSE, __VA_ARGS__)
20 #define ACC_LOG_DEBUG(...) ACC_LOG(ACC_LOG_LEVEL_DEBUG, __VA_ARGS__)
21
22 #define ACC_LOG_SIGN(a) (((a) < 0.0f) ? (-1.0f) : (1.0f))
23 #define ACC_LOG_FLOAT_INT(a) ((unsigned long int)((a) + 0.0000005f))
24 #define ACC_LOG_FLOAT_DEC(a) (unsigned long int)((1000000.0f * (((a) + 0.0000005f) - ((unsigned int)((a) + 0.0000005f)))))
25
26 #define ACC_LOG_FLOAT_TO_INTEGER(a) (((a) < 0.0f) ? "-" : ""), ACC_LOG_FLOAT_INT((a) * ACC_LOG_SIGN(a)), ACC_LOG_FLOAT_DEC((a) * ACC_LOG_SIGN(a))
27
28 /**
29 * @brief Specifier for printing float type using integers.
30 */
31 #define PRIfloat "s%lu.%06lu"
32
33
34 #if defined(__GNUC__)
35 #define PRINTF_ATTRIBUTE_CHECK(a, b) __attribute__((format(printf, a, b)))
36 #else
37 #define PRINTF_ATTRIBUTE_CHECK(a, b)
38 #endif
39
40
41 /**
42 * @brief Log function
43 *
44 * This log function can be used as a complement to for example printf.
45 * It adds useful information to the log such as time and log level
46 *
47 * @param[in] level The severity level for the log
48 * @param[in] module The name of the SW module from where the log is called
49 * @param[in] format The information to be logged, same format as for printf
50 */
51 void acc_integration_log(acc_log_level_t level, const char *module, const char *format, ...) PRINTF_ATTRIBUTE_CHECK(3, 4);
52
53
54 #endif
acc_integration_log
void acc_integration_log(acc_log_level_t level, const char *module, const char *format,...)
Log function.
Definition: acc_exploration_server_stm32.c:220
acc_integration.h
PRINTF_ATTRIBUTE_CHECK
#define PRINTF_ATTRIBUTE_CHECK(a, b)
Definition: acc_integration_log.h:37
acc_log_level_t
acc_log_level_t
This enum represents the different log levels for RSS.
Definition: acc_definitions_common.h:25
acc_definitions_common.h