Colored log module

This module implements a logging module with colored output. More...

Detailed Description

This module implements a logging module with colored output.

Files

file  log_module.h
 log_module header
 

Macros

#define LOG_ERROR_ANSI_COLOR_CODE   ("\033[1;31m")
 Default ANSI color escape code for error logs. More...
 
#define LOG_WARNING_ANSI_COLOR_CODE   ("\033[1;33m")
 Default ANSI color escape code for warning logs. More...
 
#define LOG_INFO_ANSI_COLOR_CODE   ("\033[1m")
 Default ANSI color escape code for info logs. More...
 
#define LOG_DEBUG_ANSI_COLOR_CODE   ("\033[0;32m")
 Default ANSI color escape code for debug logs. More...
 
#define LOG_RESET_ANSI_COLOR_CODE   ("\033[0m")
 ANSI color escape code used for resetting color.
 

Functions

static void log_write (unsigned level, const char *format,...)
 log_write overridden function for colored output More...
 

Variables

static const char *const _ansi_codes []
 ANSI color escape codes array. More...
 

Macro Definition Documentation

◆ LOG_DEBUG_ANSI_COLOR_CODE

#define LOG_DEBUG_ANSI_COLOR_CODE   ("\033[0;32m")

Default ANSI color escape code for debug logs.

Default is green

Definition at line 67 of file log_module.h.

◆ LOG_ERROR_ANSI_COLOR_CODE

#define LOG_ERROR_ANSI_COLOR_CODE   ("\033[1;31m")

Default ANSI color escape code for error logs.

Default is bold red

Definition at line 40 of file log_module.h.

◆ LOG_INFO_ANSI_COLOR_CODE

#define LOG_INFO_ANSI_COLOR_CODE   ("\033[1m")

Default ANSI color escape code for info logs.

Default is bold white

Definition at line 58 of file log_module.h.

◆ LOG_WARNING_ANSI_COLOR_CODE

#define LOG_WARNING_ANSI_COLOR_CODE   ("\033[1;33m")

Default ANSI color escape code for warning logs.

Default is bold yellow

Definition at line 49 of file log_module.h.

Function Documentation

◆ log_write()

static void log_write ( unsigned  level,
const char *  format,
  ... 
)
inlinestatic

log_write overridden function for colored output

Parameters
[in]levelLogging level
[in]formatString format to print

Definition at line 94 of file log_module.h.

Variable Documentation

◆ _ansi_codes

const char* const _ansi_codes[]
static
Initial value:
=
{
[LOG_WARNING] = LOG_WARNING_ANSI_COLOR_CODE,
}

ANSI color escape codes array.

Internal use only

Definition at line 80 of file log_module.h.

LOG_ERROR_ANSI_COLOR_CODE
#define LOG_ERROR_ANSI_COLOR_CODE
Default ANSI color escape code for error logs.
Definition: log_module.h:40
LOG_WARNING_ANSI_COLOR_CODE
#define LOG_WARNING_ANSI_COLOR_CODE
Default ANSI color escape code for warning logs.
Definition: log_module.h:49
LOG_DEBUG_ANSI_COLOR_CODE
#define LOG_DEBUG_ANSI_COLOR_CODE
Default ANSI color escape code for debug logs.
Definition: log_module.h:67
LOG_INFO_ANSI_COLOR_CODE
#define LOG_INFO_ANSI_COLOR_CODE
Default ANSI color escape code for info logs.
Definition: log_module.h:58