Logging functions

group group_logging_func

A logging subsystem that allows run time control for the logging level.

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.

Return

cy_rslt_t

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.

cy_rslt_t cy_log_shutdown(void)

Shutdown the logging subsystem.

Return

cy_rslt_t

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.

Return

cy_rslt_t

Parameters
  • [in] platform_output: : Pointer to the platform output routine for log messages.

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.

Return

cy_rslt_t

Parameters
  • [in] platform_time: : Pointer to a platform time routine for log message time stamps.

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.

Return

cy_rslt_t

Parameters
  • [in] facility: : The facility for which to set the log level.

  • [in] level: : The new log level to use.

cy_rslt_t cy_log_set_all_levels(CY_LOG_LEVEL_T level)

Set the logging level for all facilities.

Return

cy_rslt_t

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

CY_LOG_LEVEL_T cy_log_get_facility_level(CY_LOG_FACILITY_T facility)

Get the logging level for a facility.

Return

The current log level.

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

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.

Return

cy_rslt_t

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.

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.

Return

cy_rslt_t

Parameters
  • [in] fmt: : Format control string followed by any optional arguments.

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.

Return

cy_rslt_t

Parameters
  • [in] fmt: : Format control string.

  • [in] varg: : va_list of arguments.