Connectivity Middleware Utilities Library

General Description

A logging subsystem provides a set of helper functions to manage logging in the application.

Functions

cy_rslt_t cy_log_init (CY_LOG_LEVEL_T level, log_output platform_output, platform_get_time platform_time)
 Initialize the logging subsystem. More...
 
cy_rslt_t cy_log_shutdown (void)
 Shutdown the logging subsystem. More...
 
cy_rslt_t cy_log_set_platform_output (log_output platform_output)
 Set the platform output routine for log messages. More...
 
cy_rslt_t cy_log_set_platform_time (platform_get_time platform_time)
 Set the platform routine for getting time stamps for log messages. More...
 
cy_rslt_t cy_log_set_facility_level (CY_LOG_FACILITY_T facility, CY_LOG_LEVEL_T level)
 Set the logging level for a facility. More...
 
cy_rslt_t cy_log_set_all_levels (CY_LOG_LEVEL_T level)
 Set the logging level for all facilities. More...
 
CY_LOG_LEVEL_T cy_log_get_facility_level (CY_LOG_FACILITY_T facility)
 Get the logging level for a facility. More...
 
cy_rslt_t cy_log_msg (CY_LOG_FACILITY_T facility, CY_LOG_LEVEL_T level, const char *fmt,...)
 Write a log message. More...
 
cy_rslt_t cy_log_printf (const char *fmt,...)
 Write a log message bypassing the log level check. More...
 
cy_rslt_t cy_log_vprintf (const char *fmt, va_list varg)
 Write a log message bypassing the log level check using va_list. More...
 

Function Documentation

◆ cy_log_init()

cy_rslt_t cy_log_init ( CY_LOG_LEVEL_T  level,
log_output  platform_output,
platform_get_time  platform_time 
)

Initialize the logging subsystem.

Parameters
[in]level: The initial logging level to use for all facilities.
[in]platform_output: Pointer to the function invoked by the library to output the log messages. If this argument is passed as NULL, the library prints the log output on the standard output stream (stdio).
[in]platform_time: Pointer to the function invoked by the library to get the time. If this argument is passed as NULL, the library calls cy_rtos_get_time function to get the time required for logging.
Returns
cy_rslt_t

◆ cy_log_shutdown()

cy_rslt_t cy_log_shutdown ( void  )

Shutdown the logging subsystem.

Returns
cy_rslt_t

◆ cy_log_set_platform_output()

cy_rslt_t cy_log_set_platform_output ( log_output  platform_output)

Set the platform output routine for log messages.

Note
If platform_output is NULL, log messages will be discarded.
Parameters
[in]platform_output: Pointer to the platform output routine for log messages.
Returns
cy_rslt_t

◆ cy_log_set_platform_time()

cy_rslt_t cy_log_set_platform_time ( platform_get_time  platform_time)

Set the platform routine for getting time stamps for log messages.

Note
If platform_time is NULL, cy_time_get_time() is used for time stamps.
Parameters
[in]platform_time: Pointer to a platform time routine for log message time stamps.
Returns
cy_rslt_t

◆ cy_log_set_facility_level()

cy_rslt_t cy_log_set_facility_level ( CY_LOG_FACILITY_T  facility,
CY_LOG_LEVEL_T  level 
)

Set the logging level for a facility.

Parameters
[in]facility: The facility for which to set the log level.
[in]level: The new log level to use.
Returns
cy_rslt_t

◆ cy_log_set_all_levels()

cy_rslt_t cy_log_set_all_levels ( CY_LOG_LEVEL_T  level)

Set the logging level for all facilities.

Parameters
[in]level: The new log level to use.
Returns
cy_rslt_t

◆ cy_log_get_facility_level()

CY_LOG_LEVEL_T cy_log_get_facility_level ( CY_LOG_FACILITY_T  facility)

Get the logging level for a facility.

Parameters
[in]facility: The facility for which to return the log level.
Returns
The current log level.

◆ cy_log_msg()

cy_rslt_t cy_log_msg ( CY_LOG_FACILITY_T  facility,
CY_LOG_LEVEL_T  level,
const char *  fmt,
  ... 
)

Write a log message.

Note
The format arguments are the same as for printf.
Parameters
[in]facility: The facility for the log message.
[in]level: Log level of the message.
[in]fmt: Format control string followed by any optional arguments.
Returns
cy_rslt_t

◆ cy_log_printf()

cy_rslt_t cy_log_printf ( const char *  fmt,
  ... 
)

Write a log message bypassing the log level check.

Note
The format arguments are the same as for printf.
Parameters
[in]fmt: Format control string followed by any optional arguments.
Returns
cy_rslt_t

◆ cy_log_vprintf()

cy_rslt_t cy_log_vprintf ( const char *  fmt,
va_list  varg 
)

Write a log message bypassing the log level check using va_list.

Note
The format arguments are the same as for vprintf.
Parameters
[in]fmt: Format control string.
[in]varg: va_list of arguments.
Returns
cy_rslt_t