Zigbee Protocol Controller 1.6.0
Unify Logging system

Logging library for Unify applications and components. More...

Macros

#define sl_log_byte_arr(tag, lvl, _arr, _arr_len)
 
#define COLOR_START   "\033[32;1m"
 
#define COLOR_END   "\033[0m"
 
#define sl_log_debug(tag, fmtstr, ...)    sl_log(tag, SL_LOG_DEBUG, fmtstr, ##__VA_ARGS__)
 
#define sl_log_info(tag, fmtstr, ...)    sl_log(tag, SL_LOG_INFO, fmtstr, ##__VA_ARGS__)
 
#define sl_log_warning(tag, fmtstr, ...)    sl_log(tag, SL_LOG_WARNING, fmtstr, ##__VA_ARGS__)
 
#define sl_log_error(tag, fmtstr, ...)    sl_log(tag, SL_LOG_ERROR, fmtstr, ##__VA_ARGS__)
 
#define sl_log_critical(tag, fmtstr, ...)    sl_log(tag, SL_LOG_CRITICAL, fmtstr, ##__VA_ARGS__)
 

Typedefs

typedef enum sl_log_level sl_log_level_t
 Log levels. More...
 

Enumerations

enum  sl_log_level {
  SL_LOG_DEBUG , SL_LOG_INFO , SL_LOG_WARNING , SL_LOG_ERROR ,
  SL_LOG_CRITICAL
}
 Log levels. More...
 

Functions

void sl_log_set_level (sl_log_level_t level)
 Set log level. More...
 
sl_log_level_t sl_log_get_level ()
 Get log level. More...
 
void sl_log_set_tag_level (const char *tag, sl_log_level_t level)
 Set log level for a given tag. More...
 
void sl_log_unset_tag_level (const char *tag)
 Remove tag specific log level for tag. More...
 
sl_status_t sl_log_level_from_string (const char *level, sl_log_level_t *result)
 Convert sl_log_level as string to sl_log_level_t. More...
 
void sl_log_read_config ()
 Read configuration from config library. More...
 
void sl_log (const char *const tag, sl_log_level_t level, const char *fmtstr,...)
 Write to the log. More...
 

Detailed Description

Logging library for Unify applications and components.

Logging library for Unify based on boost::log and wrapped with C headers. The logging system features log scoping and filtering. All Unify components should use the logging system for printing messages.

Macro Definition Documentation

◆ COLOR_END

#define COLOR_END   "\033[0m"

◆ COLOR_START

#define COLOR_START   "\033[32;1m"

◆ sl_log_byte_arr

#define sl_log_byte_arr (   tag,
  lvl,
  _arr,
  _arr_len 
)
Value:
{ \
char _tmp_log_arr[_arr_len * 2 + 1] = {0}; \
char *_cur_log_arr_idx = _tmp_log_arr; \
for (unsigned int _log_arr_count = 0; _log_arr_count < _arr_len; \
_log_arr_count++) { \
_cur_log_arr_idx \
+= snprintf(_cur_log_arr_idx, \
sizeof(_tmp_log_arr) - (_cur_log_arr_idx - _tmp_log_arr), \
"%02X", \
(_arr)[_log_arr_count]); \
} \
sl_log(tag, lvl, "%s\n", _tmp_log_arr); \
}

log a byte array as hex string.

◆ sl_log_critical

#define sl_log_critical (   tag,
  fmtstr,
  ... 
)     sl_log(tag, SL_LOG_CRITICAL, fmtstr, ##__VA_ARGS__)

◆ sl_log_debug

#define sl_log_debug (   tag,
  fmtstr,
  ... 
)     sl_log(tag, SL_LOG_DEBUG, fmtstr, ##__VA_ARGS__)

◆ sl_log_error

#define sl_log_error (   tag,
  fmtstr,
  ... 
)     sl_log(tag, SL_LOG_ERROR, fmtstr, ##__VA_ARGS__)

◆ sl_log_info

#define sl_log_info (   tag,
  fmtstr,
  ... 
)     sl_log(tag, SL_LOG_INFO, fmtstr, ##__VA_ARGS__)

◆ sl_log_warning

#define sl_log_warning (   tag,
  fmtstr,
  ... 
)     sl_log(tag, SL_LOG_WARNING, fmtstr, ##__VA_ARGS__)

Typedef Documentation

◆ sl_log_level_t

Log levels.

Enumeration Type Documentation

◆ sl_log_level

Log levels.

Enumerator
SL_LOG_DEBUG 
SL_LOG_INFO 
SL_LOG_WARNING 
SL_LOG_ERROR 
SL_LOG_CRITICAL 

Function Documentation

◆ sl_log()

void sl_log ( const char *const  tag,
sl_log_level_t  level,
const char *  fmtstr,
  ... 
)

Write to the log.

Parameters
tagLog tag to use
levelLog level
fmtstrFormatted string (printf style)
...arguments for the string

◆ sl_log_get_level()

sl_log_level_t sl_log_get_level ( )

Get log level.

Returns
log level

◆ sl_log_level_from_string()

sl_status_t sl_log_level_from_string ( const char *  level,
sl_log_level_t result 
)

Convert sl_log_level as string to sl_log_level_t.

Parameters
levelstring representation of sl_log_level_t, supported values are: "d", "debug" "i", "info" "w", "warning" "e", "error" "c", "critical"
result
Returns
sl_status_t

◆ sl_log_read_config()

void sl_log_read_config ( )

Read configuration from config library.

◆ sl_log_set_level()

void sl_log_set_level ( sl_log_level_t  level)

Set log level.

Parameters
levellog level

◆ sl_log_set_tag_level()

void sl_log_set_tag_level ( const char *  tag,
sl_log_level_t  level 
)

Set log level for a given tag.

This level will override the log level set in sl_log_set_level To remove a tag specific log level use sl_log_unset_tag_level

Parameters
tagtag to set log level for
levellog level to set for the tag

◆ sl_log_unset_tag_level()

void sl_log_unset_tag_level ( const char *  tag)

Remove tag specific log level for tag.

By removing the tag specific log level, the log level for the tag will use the log level set by sl_log_set_level

Parameters
tagtag to unset specific log level for