Firmware SDK
twr_log.h
1 #ifndef _TWR_LOG_H
2 #define _TWR_LOG_H
3 
4 #include <twr_common.h>
5 #include <twr_uart.h>
6 
10 
11 #ifndef TWR_LOG_UART
12 #define TWR_LOG_UART TWR_UART_UART2
13 #endif
14 
15 #ifndef TWR_LOG_BUFFER_SIZE
16 #define TWR_LOG_BUFFER_SIZE 256
17 #endif
18 
19 #define TWR_LOG_DUMP_WIDTH 8
20 
22 
23 typedef enum
24 {
27 
30 
33 
36 
39 
42 
44 
46 
47 typedef enum
48 {
51 
54 
57 
59 
60 #ifndef RELEASE
61 
65 
66 void twr_log_init(twr_log_level_t level, twr_log_timestamp_t timestamp);
67 
73 
74 void twr_log_dump(const void *buffer, size_t length, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
75 
79 
80 void twr_log_debug(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
81 
85 
86 void twr_log_info(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
87 
91 
92 void twr_log_warning(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
93 
97 
98 void twr_log_error(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
99 
100 #else
101 
102 #define twr_log_init(...)
103 #define twr_log_dump(...)
104 #define twr_log_debug(...)
105 #define twr_log_info(...)
106 #define twr_log_warning(...)
107 #define twr_log_error(...)
108 
109 #endif
110 
112 
113 #endif // _TWR_LOG_H
void void void void void twr_log_error(const char *format,...) __attribute__((format(printf
Log ERROR message (annotated in log as <E>)
twr_log_level_t
Log level.
Definition: twr_log.h:24
void void void void twr_log_warning(const char *format,...) __attribute__((format(printf
Log WARNING message (annotated in log as <W>)
void void twr_log_debug(const char *format,...) __attribute__((format(printf
Log DEBUG message (annotated in log as <D>)
twr_log_timestamp_t
Log timestamp.
Definition: twr_log.h:48
void twr_log_init(twr_log_level_t level, twr_log_timestamp_t timestamp)
Initialize logging facility.
Definition: twr_log.c:22
void twr_log_dump(const void *buffer, size_t length, const char *format,...) __attribute__((format(printf
Log DUMP message (annotated in log as <X>)
void void void twr_log_info(const char *format,...) __attribute__((format(printf
Log INFO message (annotated in log as )
@ TWR_LOG_LEVEL_OFF
Logging disabled.
Definition: twr_log.h:41
@ TWR_LOG_LEVEL_DUMP
Logging DUMP.
Definition: twr_log.h:26
@ TWR_LOG_LEVEL_WARNING
Log level WARNING.
Definition: twr_log.h:35
@ TWR_LOG_LEVEL_ERROR
Log level ERROR.
Definition: twr_log.h:38
@ TWR_LOG_LEVEL_INFO
Log level INFO.
Definition: twr_log.h:32
@ TWR_LOG_LEVEL_DEBUG
Log level DEBUG.
Definition: twr_log.h:29
@ TWR_LOG_TIMESTAMP_OFF
Timestamp logging disabled.
Definition: twr_log.h:50
@ TWR_LOG_TIMESTAMP_REL
Timestamp logging enabled (relative time format)
Definition: twr_log.h:56
@ TWR_LOG_TIMESTAMP_ABS
Timestamp logging enabled (absolute time format)
Definition: twr_log.h:53