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