m2mb API docs  25.30.004.0
m2mb API sets documentation
m2mb_trace.h
Go to the documentation of this file.
1 /* $version: 252203 */
2 /*===============================================================================================*/
3 /* >>> Copyright (C) Telit Communications S.p.A. Italy All Rights Reserved. <<< */
23 #ifndef M2M_M2MB_TRACE_H
24 #define M2M_M2MB_TRACE_H
25 
26 #include <string.h>
27 
28 /* GCC has only the standard predefined MACRO __FILE__ and there is no __MODULE__ like in RVCT dinoa*/
29 
30 
31 #if defined(unix) || defined(__unix__) || defined(__unix)
32 #define __FILENAMEI__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
33 #define __FILENAMER__ __FILENAMEI__
34 #else
35 #define __FILENAMEI__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
36 #define __FILENAMER__ (strrchr(__FILENAMEI__, '/') ? strrchr(__FILENAMEI__, '/') + 1 : __FILENAMEI__)
37 
38 #endif
39 
40 
41 #if !defined(__MODULE__)
42 #define __MODULE__ __FILENAMER__
43 #endif
44 
45 
46 
47 /* @FHB -------------------------------------------------------------------------------
48 
49  Info: Available ONLY for AZ user applications:
50  PROTOTIPE OF THE log_az.ini FILE, to be inserted in the filesystem of the module
51  in <mod> directory with AT#M2MWRITE="/mod/log_az.ini", or with QPST configurator
52  The log_az.ini will be read with m2mb_trace_init
53  if there is no log_az.ini, then the function m2mb_trace_init will set all the classes
54  to a value of M2MB_TL_DEBUG (5) and there will be no filter for the print
55  Here a copy of the file log_az.ini :
56 ***********************************************************************<<<start here>>>
57  ; conf file for appzone2 trace:
58 
59  [logport] ; if PORT= (empty) TRACE is the default value
60  PORT=TRACE ; TRACE, USB0, USB1, UART
61 
62  [class] ; LOG SEVERITY for each class. Setting class M2MB_TL_DEBUG (5) will show
63  ; also LOG, WARNING... Setting M2MB_TL_LOG will show WARNING, ERROR... and so on
64  ; setting to 0 will not show any trace
65  TC_GENERIC = 3
66  TC_SOCKET = 0 ; 0=OFF 1=M2MB_TL_FATAL 2=M2MB_TL_ERROR 3=M2MB_TL_WARNING 4=M2MB_TL_LOG 5=M2MB_TL_DEBUG
67  TC_CLOCK = 0
68  TC_PDP = 0
69  TC_GNSS = 0
70  TC_M2M_USER = 4
71  TC_FOTA = 0
72  TC_FS = 0
73  TC_QMI = 0
74  TC_SMS = 0
75  TC_INFO = 4
76  TC_LWM2M = 0
77  TC_NET = 0
78  TC_SIM = 0
79  TC_SPI = 0
80  TC_USB = 0
81  TC_NV = 1
82  TC_RTC = 0
83  TC_UART = 0
84  TC_POWER = 0
85 
86 *****************************************************************<<<end here>>>
87 
88  @FHE --------------------------------------------------------------------------------- */
89 
90 
91 
92 /* Global declarations ==========================================================================*/
93 #define m2mb_trace_printf( _class, level, format, ... ) \
94  m2mb_trace_print_##level( _class, level, format, ##__VA_ARGS__ )
95 
96 #if !defined(M2MB_TRACE_LEVEL_FATAL_DISABLED)
97 #define m2mb_trace_print_M2MB_TL_FATAL( _class, level, format, ... ) \
98  m2mb_trace_file_line_printf(__MODULE__, __LINE__, _class, level, format, ##__VA_ARGS__)
99 #else
100 #define m2mb_trace_print_M2MB_TL_FATAL( _class, level, format, ... )
101 #endif
102 
103 #if !defined(M2MB_TRACE_LEVEL_ERROR_DISABLED)
104 #define m2mb_trace_print_M2MB_TL_ERROR( _class, level, format, ... ) \
105  m2mb_trace_file_line_printf(__MODULE__, __LINE__, _class, level, format, ##__VA_ARGS__)
106 #else
107 #define m2mb_trace_print_M2MB_TL_ERROR( _class, level, format, ... )
108 #endif
109 
110 #if !defined(M2MB_TRACE_LEVEL_WARNING_DISABLED)
111 #define m2mb_trace_print_M2MB_TL_WARNING( _class, level, format, ... ) \
112  m2mb_trace_file_line_printf(__MODULE__, __LINE__, _class, level, format, ##__VA_ARGS__)
113 #else
114 #define m2mb_trace_print_M2MB_TL_WARNING( _class, level, format, ... )
115 #endif
116 
117 #if !defined(M2MB_TRACE_LEVEL_LOG_DISABLED)
118 #define m2mb_trace_print_M2MB_TL_LOG( _class, level, format, ... ) \
119  m2mb_trace_file_line_printf(__MODULE__, __LINE__, _class, level, format, ##__VA_ARGS__)
120 #else
121 #define m2mb_trace_print_M2MB_TL_LOG( _class, level, format, ... )
122 #endif
123 
124 #if !defined(M2MB_TRACE_LEVEL_DEBUG_DISABLED)
125 #define m2mb_trace_print_M2MB_TL_DEBUG( _class, level, format, ... ) \
126  m2mb_trace_file_line_printf(__MODULE__, __LINE__, _class, level, format, ##__VA_ARGS__)
127 #else
128 #define m2mb_trace_print_M2MB_TL_DEBUG( _class, level, format, ... )
129 #endif
130 
131 /* Global typedefs ==============================================================================*/
132 
133 /*
134  typedef enum
135  {
136  M2MB_TC_GENERIC = 0,
137  M2MB_TC_SOCKET = 1,
138  M2MB_TC_CLOCK = 2,
139  M2MB_TC_PDP = 3,
140  M2MB_TC_GNSS = 4,
141  M2MB_TC_M2M_USER = 5,
142  M2MB_TC_FOTA = 6,
143  M2MB_TC_FS = 7,
144  M2MB_TC_QMI = 8,
145  M2MB_TC_SMS = 9,
146  M2MB_TC_INFO = 10,
147  M2MB_TC_LWM2M = 11,
148  M2MB_TC_NET = 12,
149  M2MB_TC_SIM = 13,
150  M2MB_TC_SPI = 14,
151  M2MB_TC_USB = 15,
152  M2MB_TC_NV = 16,
153  M2MB_TC_RTC = 17,
154  M2MB_TC_UART = 18,
155  M2MB_TC_POWER = 19,
156  M2MB_TC_FTPC = 20,
157  M2MB_TC_ATI = 21,
158  M2MB_TC_BACKUP = 22,
159  M2MB_TC_NIPD = 23,
160  M2MB_TC_SYS = 24,
161  M2MB_TC_PSM = 25,
162  M2MB_TC_SSL = 26
163  NUM_M2MB_TC
164  } M2MB_TRACE_CLASS;
165 
166 */
167 
168 /* Parse SUBSYS_TRACE_TABLE into a struct using X-Macros
169  the result will be an enum like the commented one above
170 */
171 
172 #define SUBSYS_TRACE_TABLE \
173  SUB_TR_AZ(M2MB_TC_GENERIC, "TC_GENERIC") \
174  SUB_TR_AZ(M2MB_TC_SOCKET, "TC_SOCKET") \
175  SUB_TR_AZ(M2MB_TC_CLOCK, "TC_CLOCK") \
176  SUB_TR_AZ(M2MB_TC_PDP, "TC_PDP") \
177  SUB_TR_AZ(M2MB_TC_GNSS, "TC_GNSS") \
178  SUB_TR_AZ(M2MB_TC_M2M_USER, "TC_M2M_USER") \
179  SUB_TR_AZ(M2MB_TC_FOTA, "TC_FOTA") \
180  SUB_TR_AZ(M2MB_TC_FS, "TC_FS") \
181  SUB_TR_AZ(M2MB_TC_QMI, "TC_QMI") \
182  SUB_TR_AZ(M2MB_TC_SMS, "TC_SMS") \
183  SUB_TR_AZ(M2MB_TC_INFO, "TC_INFO") \
184  SUB_TR_AZ(M2MB_TC_LWM2M, "TC_LWM2M") \
185  SUB_TR_AZ(M2MB_TC_NET, "TC_NET") \
186  SUB_TR_AZ(M2MB_TC_SIM, "TC_SIM") \
187  SUB_TR_AZ(M2MB_TC_SPI, "TC_SPI") \
188  SUB_TR_AZ(M2MB_TC_USB, "TC_USB") \
189  SUB_TR_AZ(M2MB_TC_NV, "TC_NV") \
190  SUB_TR_AZ(M2MB_TC_RTC, "TC_RTC") \
191  SUB_TR_AZ(M2MB_TC_UART, "TC_UART") \
192  SUB_TR_AZ(M2MB_TC_POWER, "TC_POWER") \
193  SUB_TR_AZ(M2MB_TC_FTPC, "TC_FTPC") \
194  SUB_TR_AZ(M2MB_TC_ATI, "TC_ATI") \
195  SUB_TR_AZ(M2MB_TC_BACKUP, "TC_BACKUP") \
196  SUB_TR_AZ(M2MB_TC_NIPD, "TC_NIPD") \
197  SUB_TR_AZ(M2MB_TC_SYS, "TC_SYS") \
198  SUB_TR_AZ(M2MB_TC_PSM, "TC_PSM") \
199  SUB_TR_AZ(M2MB_TC_SSL, "TC_SSL")
200 
201 #define SUB_TR_AZ(a, b) a,
202 typedef enum
203 {
204  SUBSYS_TRACE_TABLE
205  NUM_M2MB_TC,
206  ENUM_TO_INT( M2MB_TRACE_CLASS )
207 } M2MB_TRACE_CLASS;
208 #undef SUB_TR_AZ
209 
210 
211 /*
212  LOG SEVERITY enum for the trace.
213  if in the ini file the log severity is set for example to M2MB_TL_LOG (4), then all
214  the log with inferior severity will be shown, but not M2MB_TL_DEBUG (5)
215 */
216 
217 typedef enum
218 {
219  M2MB_TL_FATAL = 1,
220  M2MB_TL_ERROR = 2,
221  M2MB_TL_WARNING = 3,
222  M2MB_TL_LOG = 4,
223  M2MB_TL_DEBUG = 5,
224  NUM_M2MB_TL,
225  ENUM_TO_INT( M2MB_TRACE_LEVEL )
226 } M2MB_TRACE_LEVEL;
227 
228 /*
229  Type of output for logs, to be set only in log_az.ini.
230  Without the ini file the log will always be on trace
231 */
232 typedef enum
233 {
234  LOG_TRACE, /* TRACE in the log_az.ini file */
235  LOG_USB0, /* USB0 in the log_az.ini file */
236  LOG_USB1, /* USB1 in the log_az.ini file */
237  LOG_UART, /* UART in the log_az.ini file */
238  ENUM_TO_INT( M2MB_TRACE_OUTPUT_TYPE )
239 } M2MB_TRACE_OUTPUT_TYPE;
240 
241 typedef HANDLE M2MB_TRACE_HANDLE;
242 
243 /* Global functions =============================================================================*/
244 /*-----------------------------------------------------------------------------------------------*/
265 /*-----------------------------------------------------------------------------------------------*/
266 M2MB_RESULT_E m2mb_trace_init
267 (
268  void
269 );
270 
271 /*-----------------------------------------------------------------------------------------------*/
291 /*-----------------------------------------------------------------------------------------------*/
292 M2MB_RESULT_E m2mb_trace_deinit
293 (
294  void
295 );
296 
297 
298 /*-----------------------------------------------------------------------------------------------*/
323 /*-----------------------------------------------------------------------------------------------*/
324 M2MB_RESULT_E m2mb_trace_enable
325 (
326  M2MB_TRACE_CLASS traceClass
327 );
328 
329 /*-----------------------------------------------------------------------------------------------*/
353 /*-----------------------------------------------------------------------------------------------*/
354 M2MB_RESULT_E m2mb_trace_disable
355 (
356  M2MB_TRACE_CLASS traceClass
357 );
358 
359 /*-----------------------------------------------------------------------------------------------*/
360 
361 /*-----------------------------------------------------------------------------------------------*/
398 /*-----------------------------------------------------------------------------------------------*/
399 M2MB_RESULT_E m2mb_trace_file_line_printf
400 (
401  const char *file,
402  int line,
403  M2MB_TRACE_CLASS _class,
404  M2MB_TRACE_LEVEL level,
405  char *fmt,
406  ...
407 );
408 
409 #endif /* M2M_M2MB_TRACE_H */
410 
m2mb_trace_enable
M2MB_RESULT_E m2mb_trace_enable(M2MB_TRACE_CLASS traceClass)
Base trace abilitation.
m2mb_trace_disable
M2MB_RESULT_E m2mb_trace_disable(M2MB_TRACE_CLASS traceClass)
Base trace disabilitation.
m2mb_trace_init
M2MB_RESULT_E m2mb_trace_init(void)
Base trace system initializazion.
m2mb_trace_deinit
M2MB_RESULT_E m2mb_trace_deinit(void)
Base trace system deinitializazion.
m2mb_trace_file_line_printf
M2MB_RESULT_E m2mb_trace_file_line_printf(const char *file, int line, M2MB_TRACE_CLASS _class, M2MB_TRACE_LEVEL level, char *fmt,...)
Base trace printf with file and line info.