m2mb API docs  25.30.003
m2mb API sets documentation
m2mb_trace.h File Reference

Base trace system for m2m application. More...

#include <string.h>

Go to the source code of this file.

Macros

#define __FILENAMEI__   (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
 
#define __FILENAMER__   (strrchr(__FILENAMEI__, '/') ? strrchr(__FILENAMEI__, '/') + 1 : __FILENAMEI__)
 
#define __MODULE__   __FILENAMER__
 
#define m2mb_trace_printf(_class, level, format, ...)   m2mb_trace_print_##level( _class, level, format, ##__VA_ARGS__ )
 
#define m2mb_trace_print_M2MB_TL_FATAL(_class, level, format, ...)   m2mb_trace_file_line_printf(__MODULE__, __LINE__, _class, level, format, ##__VA_ARGS__)
 
#define m2mb_trace_print_M2MB_TL_ERROR(_class, level, format, ...)   m2mb_trace_file_line_printf(__MODULE__, __LINE__, _class, level, format, ##__VA_ARGS__)
 
#define m2mb_trace_print_M2MB_TL_WARNING(_class, level, format, ...)   m2mb_trace_file_line_printf(__MODULE__, __LINE__, _class, level, format, ##__VA_ARGS__)
 
#define m2mb_trace_print_M2MB_TL_LOG(_class, level, format, ...)   m2mb_trace_file_line_printf(__MODULE__, __LINE__, _class, level, format, ##__VA_ARGS__)
 
#define m2mb_trace_print_M2MB_TL_DEBUG(_class, level, format, ...)   m2mb_trace_file_line_printf(__MODULE__, __LINE__, _class, level, format, ##__VA_ARGS__)
 
#define SUBSYS_TRACE_TABLE
 
#define SUB_TR_AZ(a, b)   a,
 

Typedefs

typedef HANDLE M2MB_TRACE_HANDLE
 

Enumerations

enum  M2MB_TRACE_CLASS { NUM_M2MB_TC }
 
enum  M2MB_TRACE_LEVEL {
  M2MB_TL_FATAL = 1, M2MB_TL_ERROR = 2, M2MB_TL_WARNING = 3, M2MB_TL_LOG = 4,
  M2MB_TL_DEBUG = 5, NUM_M2MB_TL
}
 
enum  M2MB_TRACE_OUTPUT_TYPE { LOG_TRACE, LOG_USB0, LOG_USB1, LOG_UART }
 

Functions

M2MB_RESULT_E m2mb_trace_init (void)
 Base trace system initializazion. More...
 
M2MB_RESULT_E m2mb_trace_deinit (void)
 Base trace system deinitializazion. More...
 
M2MB_RESULT_E m2mb_trace_enable (M2MB_TRACE_CLASS traceClass)
 Base trace abilitation. More...
 
M2MB_RESULT_E m2mb_trace_disable (M2MB_TRACE_CLASS traceClass)
 Base trace disabilitation. More...
 
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. More...
 

Detailed Description

Base trace system for m2m application.

m2m/m2m_common/m2mb_inc/m2mb_trace.h

@notes Dependencies: stdarg.h, m2mb_types.h

Author
mb_ dinoa
Date
17/02/2017 05/04/2018

Macro Definition Documentation

◆ SUBSYS_TRACE_TABLE

#define SUBSYS_TRACE_TABLE
Value:
SUB_TR_AZ(M2MB_TC_GENERIC, "TC_GENERIC") \
SUB_TR_AZ(M2MB_TC_SOCKET, "TC_SOCKET") \
SUB_TR_AZ(M2MB_TC_CLOCK, "TC_CLOCK") \
SUB_TR_AZ(M2MB_TC_PDP, "TC_PDP") \
SUB_TR_AZ(M2MB_TC_GNSS, "TC_GNSS") \
SUB_TR_AZ(M2MB_TC_M2M_USER, "TC_M2M_USER") \
SUB_TR_AZ(M2MB_TC_FOTA, "TC_FOTA") \
SUB_TR_AZ(M2MB_TC_FS, "TC_FS") \
SUB_TR_AZ(M2MB_TC_QMI, "TC_QMI") \
SUB_TR_AZ(M2MB_TC_SMS, "TC_SMS") \
SUB_TR_AZ(M2MB_TC_INFO, "TC_INFO") \
SUB_TR_AZ(M2MB_TC_LWM2M, "TC_LWM2M") \
SUB_TR_AZ(M2MB_TC_NET, "TC_NET") \
SUB_TR_AZ(M2MB_TC_SIM, "TC_SIM") \
SUB_TR_AZ(M2MB_TC_SPI, "TC_SPI") \
SUB_TR_AZ(M2MB_TC_USB, "TC_USB") \
SUB_TR_AZ(M2MB_TC_NV, "TC_NV") \
SUB_TR_AZ(M2MB_TC_RTC, "TC_RTC") \
SUB_TR_AZ(M2MB_TC_UART, "TC_UART") \
SUB_TR_AZ(M2MB_TC_POWER, "TC_POWER") \
SUB_TR_AZ(M2MB_TC_FTPC, "TC_FTPC") \
SUB_TR_AZ(M2MB_TC_ATI, "TC_ATI") \
SUB_TR_AZ(M2MB_TC_BACKUP, "TC_BACKUP") \
SUB_TR_AZ(M2MB_TC_NIPD, "TC_NIPD") \
SUB_TR_AZ(M2MB_TC_SYS, "TC_SYS") \
SUB_TR_AZ(M2MB_TC_PSM, "TC_PSM") \
SUB_TR_AZ(M2MB_TC_SSL, "TC_SSL")

Function Documentation

◆ m2mb_trace_deinit()

M2MB_RESULT_E m2mb_trace_deinit ( void  )

Base trace system deinitializazion.

This function deinitialize and free the structure needed for the trace If there are no other log connections from other Apps close also the ports USB/UART open (if any)

Returns
M2MB_RESULT_SUCCESS - Ok
See M2MB_RESULT_E for error codes

Example

M2MB_RESULT_E Ret = m2mb_trace_deinit();

◆ m2mb_trace_disable()

M2MB_RESULT_E m2mb_trace_disable ( M2MB_TRACE_CLASS  traceClass)

Base trace disabilitation.

This function disaables a specific trace class

Parameters
[in]traceClassClass of the trace to be disabled If the log is not active, doesn't do anything. If the traceClass deactivated is the only active, it deactivates the trace
Returns
M2MB_RESULT_SUCCESS - Ok
See M2MB_RESULT_E for error codes

Example

M2MB_RESULT_E Ret = m2mb_trace_disable(M2MB_TC_GENERIC);

◆ m2mb_trace_enable()

M2MB_RESULT_E m2mb_trace_enable ( M2MB_TRACE_CLASS  traceClass)

Base trace abilitation.

This function enables a specific trace class

Parameters
[in]traceClassClass of the trace to be enabled at a M2MB_TRACE_LEVEL of M2MB_TL_DEBUG (5) If it is used after m2mb_trace_init, it activates the selected trace class. If it is used before or instead of m2mb_trace_init, it bypasses any reading of log_az.ini and activates the trace as LOG_TRACE with only the selected trace class activated
Returns
M2MB_RESULT_SUCCESS - Ok
See M2MB_RESULT_E for error codes

Example

M2MB_RESULT_E Ret = m2mb_trace_enable(M2MB_TC_GENERIC);

◆ 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.

Print formatted data to to trace system including file and line information.

Parameters
[in]fileString containing the name of the file from where the trace is called
[in]lineString containing the line in the file from where the trace is called
[in]traceClassEnum from M2MB_TRACE_CLASS that specifies class of the trace
[in]levelEnum from M2MB_TRACE_LEVEL that specifies level of the trace
[in]fmtFormat string for printf
[in]...Unnamed arguments
Returns
M2MB_RESULT_SUCCESS - Ok
See M2MB_RESULT_E for error codes

Example

#include <stdarg.h>
M2MB_RESULT_E ret;
ret = m2mb_trace_file_line_printf(__MODULE__, __LINE__, M2MB_TC_GENERIC, "%s", "Test");

◆ m2mb_trace_init()

M2MB_RESULT_E m2mb_trace_init ( void  )

Base trace system initializazion.

This function collects all necessary initializatione for the base trace system If there is no log_az.ini, all the classes to a M2MB_TRACE_LEVEL of M2MB_TL_DEBUG (5), that is all traces will be shown. ( user case )

Returns
M2MB_RESULT_SUCCESS - Ok
See M2MB_RESULT_E for error codes

Example

M2MB_RESULT_E Ret = m2mb_trace_init();
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.