Maestro Audio Framework v 1.7
NXP Semiconductors
Loading...
Searching...
No Matches
maestro_logging.h File Reference

Contains maestro_logging prototypes and definitions for the connected radio. More...

Macros

#define LOGMDL_MAX_MODULES   6
 Maximum number of modules supported.
 
#define LOGMDL_MAX_ERRORS   17
 Maximum number of modules supported.
 
#define LOG_NAME_LENGTH   19
 Maximum string length for module name.
 
#define LOG_ENABLED
 Logging enabled.
 
The level of the error will be defined as:
#define LOGLVL_CATASTROPHIC   0x01
 Serious error. System cannot recover.
 
#define LOGLVL_ERROR    0x02
 An error has occurred. The system should \ be able to continue but an individual \ module may not be able to.
 
#define LOGLVL_WARNING   0x04
 A warning about a potential problem.
 
#define LOGLVL_INFO    0x08
 Information that could be useful to the \ user.
 
#define LOGLVL_DEBUG   0x10
 For developers for debugging.
 
#define LOGLVL_FUNCTION_INFO    0x20
 For developers debugging. Function \ Enter/Exit info.
 
Additional level specifications used by set_debug_level()

These levels cannot be used by lprintf()

#define LOGLVL_NONE   0x00
 No error messages reported.
 
#define LOGLVL_DEFAULT   0x03
 Default log level.
 
#define LOGLVL_ALL   0xFF
 All error messages reported.
 
Output location for the error logs
#define LOGPUT_NONE   0x0
 No output.
 
#define LOGPUT_CONSOLE   0x1
 Output goes to the terminal window.
 
#define LOGPUT_FILE   0x2
 Output goes to a file.
 
#define LOGPUT_ALL   0x3
 Output to all possibilities.
 
The module bit field definition.

The modules will be defined as bit settings in a 32 bit value so this is limited to 32 modules.

#define LOGMDL_COMMON   0x00000001
 Common module.
 
#define LOGMDL_OSA   0x00000002
 OSA module.
 
#define LOGMDL_APP   0x00000004
 Application module.
 
#define LOGMDL_GUI   0x00000008
 GUI module.
 
#define LOGMDL_STREAMER   0x00000010
 Streamer module.
 
Additional level specifications used by set_debug_module()

These levels cannot be used by lprintf(). The user can also OR several modules together for a custom selection.

#define LOGMDL_NONE   0x00000000
 None module allowed.
 
#define LOGMDL_ALL   0x3FFFFFFF
 All modulew allowed.
 

LOGGING FUNCTION PROTOTYPES

#define LOG_ENTER(module)   lprintf(module, LOGLVL_FUNCTION_INFO, 0, "Entering: %s\n", __FUNCTION__)
 Convenience function that prints a debug level message specifically for entering a function.
 
#define LOG_EXIT(module)   lprintf(module, LOGLVL_FUNCTION_INFO, 0, "Exiting: %s\n\n", __FUNCTION__)
 Convenience function that prints a debug level message specifically for exiting a function.
 
void lprintf (const uint32_t module, const uint8_t level, const uint32_t error, const char *message,...)
 The function lprintf() is used in module code in place of printf(). Different levels of information can be turned on or off at runtime for specific modules.
 
void dlprintf (const uint32_t module, const char *message,...)
 This function is the information-specific shortcut variant of lprintf(). It is the same as specifying lprintf(module, LOGLVL_DEBUG, ERRCODE_NO_ERROR, ...).
 
void ilprintf (const uint32_t module, const char *message,...)
 This function is the information-specific shortcut variant of lprintf(). It is the same as specifying lprintf(module, LOGLVL_INFO, ERRCODE_NO_ERROR, ...).
 
void set_debug_module (const uint32_t module)
 Sets the module of interest based on bits set in module. Adds to any already set.
 
void set_debug_level (const uint8_t level)
 Sets the levels to display based on bits set in level. Adds to those already set.
 
void set_debug_out (const uint8_t output)
 Indicates where the output should go: to the console, a file, etc.
 
void clear_debug_module (const uint32_t module)
 Clears the modules set in module.
 
void clear_debug_level (const uint8_t level)
 Clears the levels set in level.
 
void clear_debug_out (const uint8_t output)
 Clears the output bits set in output.
 
uint32_t add_module_name (const uint32_t module, const char *name)
 Adds a name for a module to the system. The module name will be printed with the output of lprintf().
 
uint32_t remove_module_name (const uint32_t module)
 Removes the name for a module.
 
uint32_t add_error_name (const uint32_t error_id, const char *text)
 Adds a text string for an error of 25 char or less to the system. The error text will be printed with the output of lprintf().
 
char * error_name (const uint32_t error_id)
 Returns a simple name for an error code, if it was pre-set with add_error_name().
 
void init_logging (void)
 Initializes the module and error tables.
 
void deinit_logging (void)
 Deinitializes the module.
 
void get_debug_state (void)
 Prints the settings for active modules, level and output.
 

Macro Definition Documentation

◆ LOG_ENTER

#define LOG_ENTER ( module)    lprintf(module, LOGLVL_FUNCTION_INFO, 0, "Entering: %s\n", __FUNCTION__)
Parameters
[in]modulemodule id

◆ LOG_EXIT

#define LOG_EXIT ( module)    lprintf(module, LOGLVL_FUNCTION_INFO, 0, "Exiting: %s\n\n", __FUNCTION__)
Parameters
[in]modulemodule id

Function Documentation

◆ lprintf()

void lprintf ( const uint32_t module,
const uint8_t level,
const uint32_t error,
const char * message,
... )
Parameters
[in]moduleis an enumerated value defining the module this is used in
[in]levelis an enumerated value indicating the seriousness of the error
[in]erroris a defined error/warning code
[in]messageis a text message describing the error. The message can use args just as a standard printf.

◆ dlprintf()

void dlprintf ( const uint32_t module,
const char * message,
... )
Parameters
[in]moduleis an enumerated value defining the module this is used in
[in]messageis a text message describing the error. The message can use args just as a standard printf.

◆ ilprintf()

void ilprintf ( const uint32_t module,
const char * message,
... )
Parameters
[in]moduleis an enumerated value defining the module that this is used in
[in]messageis a text message describing the error. The message can use args just as a standard printf.

◆ set_debug_module()

void set_debug_module ( const uint32_t module)
Parameters
[in]modulebit(s) to be added to active modules. This value is generated by or'ing the LOGMDL_* defines.

◆ set_debug_level()

void set_debug_level ( const uint8_t level)
Parameters
[in]levelbit(s) to be added to active levels. This value is generated by or'ing the LOGLVL_* defines.

◆ set_debug_out()

void set_debug_out ( const uint8_t output)
Parameters
[in]outputbit(s) to be added to active output. This should be one of the LOGPUT_* defines.

◆ clear_debug_module()

void clear_debug_module ( const uint32_t module)
Parameters
[in]modulebit(s) to be cleared in active modules. This value is generated by or'ing the LOGMDL_* defines.

◆ clear_debug_level()

void clear_debug_level ( const uint8_t level)
Parameters
[in]levelbit(s) to be removed from active levels. This value is generated by or'ing the LOGLVL_* defines.

◆ clear_debug_out()

void clear_debug_out ( const uint8_t output)
Parameters
[in]outputbit(s) to be removed from active output. This should be one of the LOGPUT_* defines.

◆ add_module_name()

uint32_t add_module_name ( const uint32_t module,
const char * name )
Parameters
[in]moduleid of a module
[in]namename for the module
Returns
an error code. The error code can be:
Return values
ERRCODE_NO_ERRORworked as expected
ERRCODE_PARAMETER_EXISTSthe module id already has a name
ERRCODE_SYSTEM_LIMITthe system has run out of places to store module information

◆ remove_module_name()

uint32_t remove_module_name ( const uint32_t module)
Parameters
[in]moduleid of a module
Returns
an error code. The error code can be:
Return values
ERRCODE_NO_ERRORworked as expected
ERRCODE_NOT_FOUNDno text was found for this module

◆ add_error_name()

uint32_t add_error_name ( const uint32_t error_id,
const char * text )
Parameters
[in]error_iderror the text will be added to
[in]texterror text to be printed for error_id
Returns
an error code. The error code can be:
Return values
ERRCODE_NO_ERRORworked as expected
ERRCODE_PARAMETER_EXISTSthe error id already has identifying text
ERRCODE_SYSTEM_LIMITthe system has run out of places to store error information

◆ error_name()

char * error_name ( const uint32_t error_id)
Parameters
[in]error_idan error code indicating a particular error
Returns
a descriptive text identification will be returned for this error id