log_util.c File Reference

Log utility module implementation file. More...

#include "log_util.h"
#include "mcl_core/mcl_assert.h"
#include <stdarg.h>
#include <stdio.h>
Include dependency graph for log_util.c:

Go to the source code of this file.

Functions

static void _mcl_log_util_default_callback (void *user_context, int log_level, const char *file, int line, const char *tag, const char *const format,...)
 
mcl_error_t mcl_log_util_set_output_level (const int log_level)
 
int mcl_log_util_get_output_level (void)
 
mcl_error_t mcl_log_util_set_callback (mcl_log_util_callback_t callback, void *user_context)
 

Variables

static int _mcl_log_level = MCL_LOG_LEVEL
 
mcl_log_util_callback_t mcl_log_util_function = _mcl_log_util_default_callback
 
void * mcl_log_util_user_context = NULL
 
static const char * _mcl_level_strings []
 

Detailed Description

Log utility module implementation file.

Definition in file log_util.c.

Function Documentation

static void _mcl_log_util_default_callback ( void *  user_context,
int  log_level,
const char *  file,
int  line,
const char *  tag,
const char *const  format,
  ... 
)
static

Definition at line 81 of file log_util.c.

References _mcl_level_strings, and MCL_LOG_LEVEL_VERBOSE.

int mcl_log_util_get_output_level ( void  )

This function is used to get log output level.

Returns
  • Output level of log utility.

Definition at line 51 of file log_util.c.

References _mcl_log_level, and MCL_LOG_LEVEL_NONE.

mcl_error_t mcl_log_util_set_callback ( mcl_log_util_callback_t  callback,
void *  user_context 
)

This function is used to set callback function for log utility.

Parameters
[in]callbackCallback function.
[in]user_contextUser context argument.
Returns

Definition at line 60 of file log_util.c.

References MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FAIL, MCL_FUNCTION_LEAVE_LABEL, mcl_log_util_function, mcl_log_util_user_context, and MCL_OK.

mcl_error_t mcl_log_util_set_output_level ( const int  log_level)

This function sets the output level. The output level is used during runtime check. No logs are written if given log level is below this output level.

Parameters
[in]log_levelThe output level to set with. Following log levels can be set.
  • MCL_LOG_LEVEL_VERBOSE. //!< All other events.
  • MCL_LOG_LEVEL_DEBUG. //!< Minimal set of events that could help to reconstruct the execution path.
  • MCL_LOG_LEVEL_INFO. //!< Significant life cycle event or major state transition happened.
  • MCL_LOG_LEVEL_WARN. //!< Something that usually should not occur happened and significantly changes application behavior for some period of time.
  • MCL_LOG_LEVEL_ERROR. //!< Something possible, but highly unexpected happened. The process is able to recover and continue execution.
  • MCL_LOG_LEVEL_FATAL. //!< Something impossible and absolutely unexpected happened. Process can't continue and must be terminated.
  • MCL_LOG_LEVEL_NONE. //!< None.
Returns

Definition at line 33 of file log_util.c.

References _mcl_log_level, MCL_INVALID_LOG_LEVEL, MCL_LOG_LEVEL, MCL_LOG_LEVEL_FATAL, MCL_LOG_LEVEL_NONE, and MCL_OK.

Variable Documentation

const char* _mcl_level_strings[]
static
Initial value:
=
{
"VERBOSE",
"DEBUG",
"INFO",
"WARN",
"ERROR",
"FATAL"
}

Definition at line 22 of file log_util.c.

Referenced by _mcl_log_util_default_callback().

int _mcl_log_level = MCL_LOG_LEVEL
static

Definition at line 17 of file log_util.c.

Referenced by mcl_log_util_get_output_level(), and mcl_log_util_set_output_level().

Definition at line 19 of file log_util.c.

Referenced by mbedtls_debug_function(), and mcl_log_util_set_callback().

void* mcl_log_util_user_context = NULL

Definition at line 20 of file log_util.c.

Referenced by mbedtls_debug_function(), and mcl_log_util_set_callback().