log.c
int log_enabled(const char *fmt, enum log_level *fmt_log_level)
{
  if (fmt == NULL)
    {
      return 0;
    }

  /* set log level to info only to make unconditional message print in INFO
   * color */

  *fmt_log_level = LOG_LEVEL_INFO;

  if (fmt[1] != '/')
    {
      /* Log string doesn't contain log level information, print it anyway */

      return 1;
    }

  switch (fmt[0])
    {
    case 'D': *fmt_log_level = LOG_LEVEL_DEBUG; break;
    case 'I': *fmt_log_level = LOG_LEVEL_INFO; break;
    case 'W': *fmt_log_level = LOG_LEVEL_WARNING; break;
    case 'E': *fmt_log_level = LOG_LEVEL_ERROR; break;

    /* If log level is not recognized we unconditionally allow log print. */

    default: return 1;
    }

  if (*fmt_log_level <= log_level)
    {
      return 1;
    }

  /* No contidion to allow printing has been met */

  return 0;
}
/*****************************************************************************
 * Name: log_enabled
 *
 * Description:
 *   Checks if log string pointed by fmt should be logged or not. It also
 *   stores enum of log_level in parameter fmt_log_level
 *
 * Input Parameters:
 *   fmt: Log string
 *
 * Output Parameters:
 *   fmt_log_level: enum representation of log level
 *
 * Output Values:
 *   0: Log is NOT enabled for given fmt
 *   1: Log is enabled for given fmt
 ****************************************************************************/
log_enabled
Description:
Checks if log string pointed by fmt should be logged or not. It also
stores enum of log_level in parameter fmt_log_level

Input Parameters:
fmt: Log string

Output Parameters:
fmt_log_level: enum representation of log level

Output Values:
0: Log is NOT enabled for given fmt
1: Log is enabled for given fmt
log_enabled Description : Checks if log string pointed by fmt should be logged or not . It also stores enum of log_level in parameter fmt_log_level Input Parameters : fmt : Log string Output Parameters : fmt_log_level : enum representation of log level Output Values : 0 : Log is NOT enabled for given fmt 1 : Log is enabled for given fmt
int log_enabled(const char *fmt, enum log_level *fmt_log_level)
{
  if (fmt == NULL)
    {
      return 0;
    }
  *fmt_log_level = LOG_LEVEL_INFO;
  if (fmt[1] != '/')
    {
      return 1;
    }
  switch (fmt[0])
    {
    case 'D': *fmt_log_level = LOG_LEVEL_DEBUG; break;
    case 'I': *fmt_log_level = LOG_LEVEL_INFO; break;
    case 'W': *fmt_log_level = LOG_LEVEL_WARNING; break;
    case 'E': *fmt_log_level = LOG_LEVEL_ERROR; break;
    default: return 1;
    }
  if (*fmt_log_level <= log_level)
    {
      return 1;
    }
  return 0;
}
int log_enabled ( const char * fmt , enum log_level * fmt_log_level ) { if ( fmt == NULL ) { return 0 ; } * fmt_log_level = LOG_LEVEL_INFO ; if ( fmt [ 1 ] != ' ' ) { return 1 ; } switch ( fmt [ 0 ] ) { case ' ' : * fmt_log_level = LOG_LEVEL_DEBUG ; break ; case ' ' : * fmt_log_level = LOG_LEVEL_INFO ; break ; case ' ' : * fmt_log_level = LOG_LEVEL_WARNING ; break ; case ' ' : * fmt_log_level = LOG_LEVEL_ERROR ; break ; default : return 1 ; } if ( * fmt_log_level <= log_level ) { return 1 ; } return 0 ; }
Name: log_enabled
 Description:
   Checks if log string pointed by fmt should be logged or not.
Name : log_enabled Description : Checks if log string pointed by fmt should be logged or not .
/* set log level to info only to make unconditional message print in INFO
   * color */ /* Log string doesn't contain log level information, print it anyway */ /* If log level is not recognized we unconditionally allow log print. */ /* No contidion to allow printing has been met */