OPTIGA™ Trust M
Host Library Documentation
optiga_lib_logger.h
Go to the documentation of this file.
1 
38 #ifndef _OPTIGA_LIB_LOGGER_H_
39 #define _OPTIGA_LIB_LOGGER_H_
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
46 
47 //Logger levels
48 #define OPTIGA_UTIL_SERVICE "[optiga util] : "
49 #define OPTIGA_CRYPT_SERVICE "[optiga crypt] : "
50 #define OPTIGA_COMMAND_LAYER "[optiga cmd] : "
51 #define OPTIGA_COMMUNICATION_LAYER "[optiga comms] : "
52 
53 
54 // Logger colors options
55 #define OPTIGA_LIB_LOGGER_COLOR_RED "\x1b[31m"
56 #define OPTIGA_LIB_LOGGER_COLOR_GREEN "\x1b[32m"
57 #define OPTIGA_LIB_LOGGER_COLOR_YELLOW "\x1b[33m"
58 #define OPTIGA_LIB_LOGGER_COLOR_BLUE "\x1b[34m"
59 #define OPTIGA_LIB_LOGGER_COLOR_MAGENTA "\x1b[35m"
60 #define OPTIGA_LIB_LOGGER_COLOR_CYAN "\x1b[36m"
61 #define OPTIGA_LIB_LOGGER_COLOR_LIGHT_GREY "\x1b[90m"
62 #define OPTIGA_LIB_LOGGER_COLOR_LIGHT_RED "\x1b[91m"
63 #define OPTIGA_LIB_LOGGER_COLOR_LIGHT_GREEN "\x1b[92m"
64 #define OPTIGA_LIB_LOGGER_COLOR_LIGHT_YELLOW "\x1b[93m"
65 #define OPTIGA_LIB_LOGGER_COLOR_LIGHT_BLUE "\x1b[94m"
66 #define OPTIGA_LIB_LOGGER_COLOR_LIGHT_MAGENTA "\x1b[95m"
67 #define OPTIGA_LIB_LOGGER_COLOR_LIGHT_CYAN "\x1b[96m"
68 #define OPTIGA_LIB_LOGGER_COLOR_DEFAULT "\x1b[0m"
69 
70 // Logger color for different layers and data
71 #define OPTIGA_UTIL_SERVICE_COLOR OPTIGA_LIB_LOGGER_COLOR_DEFAULT
72 #define OPTIGA_CRYPT_SERVICE_COLOR OPTIGA_LIB_LOGGER_COLOR_DEFAULT
73 #define OPTIGA_COMMAND_LAYER_COLOR OPTIGA_LIB_LOGGER_COLOR_DEFAULT
74 #define OPTIGA_COMMUNICATION_LAYER_COLOR OPTIGA_LIB_LOGGER_COLOR_DEFAULT
75 #define OPTIGA_ERROR_COLOR OPTIGA_LIB_LOGGER_COLOR_RED
76 #define OPTIGA_UNPROTECTED_DATA_COLOR OPTIGA_LIB_LOGGER_COLOR_LIGHT_CYAN
77 #define OPTIGA_PROTECTED_DATA_COLOR OPTIGA_LIB_LOGGER_COLOR_YELLOW
78 
79 #define OPTIGA_HEX_BYTE_SEPERATOR ""
80 
96 void optiga_lib_print_string(const char_t *input_string);
97 
114 void optiga_lib_print_string_with_newline(const char_t * p_log_string);
115 
134 void optiga_lib_print_message(const char_t * p_log_string,
135  const char_t * p_log_layer,
136  const char_t * p_log_color);
137 
156 void optiga_lib_print_status(const char_t * p_log_layer,
157  const char_t * p_log_color,
158  uint16_t return_value);
177 void optiga_lib_print_array_hex_format(const uint8_t * p_log_string,
178  uint16_t length,
179  const char_t * p_log_color);
180 
197 #define OPTIGA_LIB_LOGGER_PRINT_ARRAY(p_output_buffer, p_temp_buffer, p_color) \
198 { \
199  sprintf((char_t *)p_output_buffer, \
200  "%25s%s%s", \
201  p_color, \
202  p_temp_buffer, \
203  OPTIGA_LIB_LOGGER_COLOR_DEFAULT); \
204 }
205 
223 #define OPTIGA_LIB_LOGGER_PRINT_INFO(p_output_buffer, p_temp_buffer, p_layer, p_color) \
224 { \
225  sprintf((char_t *)p_output_buffer, \
226  "%s%s%s%s", \
227  p_color, \
228  p_layer, \
229  p_temp_buffer, \
230  OPTIGA_LIB_LOGGER_COLOR_DEFAULT); \
231 }
232 
233 #ifdef __cplusplus
234 }
235 #endif
236 
237 #endif /*_OPTIGA_LIB_LOGGER_H_ */
238 
optiga_lib_types.h
This file contains the type definitions for the fundamental data types.
optiga_lib_print_string_with_newline
void optiga_lib_print_string_with_newline(const char_t *p_log_string)
To log a string with a new line.
optiga_lib_print_status
void optiga_lib_print_status(const char_t *p_log_layer, const char_t *p_log_color, uint16_t return_value)
To log a return value with a new line and layer information.
optiga_lib_print_array_hex_format
void optiga_lib_print_array_hex_format(const uint8_t *p_log_string, uint16_t length, const char_t *p_log_color)
To log the byte array in hex format.
char_t
char char_t
Typedef for one byte integer.
Definition: optiga_lib_types.h:75
optiga_lib_print_message
void optiga_lib_print_message(const char_t *p_log_string, const char_t *p_log_layer, const char_t *p_log_color)
To log a string with a new line and layer information.
optiga_lib_print_string
void optiga_lib_print_string(const char_t *input_string)
To log a string.