C Everything
This is a C repository containing a curated set of generic data structures and algorithm.
logger.h File Reference

Defines Macros for logging. More...

Go to the source code of this file.

Macros

#define __LOG_ERROR__   0
 log level Error More...
 
#define __LOG_WARN__   1
 log level Warn More...
 
#define __LOG_INFO__   2
 log level Info More...
 
#define __LOG_DEBUG__   3
 log level Debug More...
 
#define __LOG_TRACE__   4
 log level Trace More...
 
#define MAX_LOG_LEVELS   5
 
#define MAX_MODULES   4
 
#define COMMON_MODULE   1
 
#define LOG_ERROR(mod, fmt, args...)   app_log(mod, __LOG_ERROR__, NULL, fmt, ##args)
 
#define LOG_WARN(mod, fmt, args...)   app_log(mod, __LOG_WARN__, NULL, fmt, ##args)
 
#define LOG_INFO(mod, fmt, args...)   app_log(mod, __LOG_INFO__, NULL, fmt, ##args)
 
#define LOG_DEBUG(mod, fmt, args...)   app_log(mod, __LOG_DEBUG__, NULL, fmt, ##args)
 
#define LOG_TRACE_IN(mod, fmt, args...)   app_log(mod, __LOG_TRACE__, NULL, "[++%s:%4d]" fmt"\n", __func__, __LINE__, ##args)
 
#define LOG_TRACE_OUT(mod, fmt, args...)   app_log(mod, __LOG_TRACE__, NULL, "[--%s:%4d]" fmt"\n", __func__, __LINE__, ##args)
 

Functions

void logger_init ()
 
Initailize logger module More...
 
int app_log (char *module, int level, char *prefix, const char *format,...)
 
Used for defining different logging modules such as warn, error, debug, trace ... More...
 

Detailed Description

Defines Macros for logging.

Definition in file logger.h.

Macro Definition Documentation

◆ __LOG_DEBUG__

#define __LOG_DEBUG__   3

log level Debug

Definition at line 10 of file logger.h.

◆ __LOG_ERROR__

#define __LOG_ERROR__   0

log level Error

Definition at line 7 of file logger.h.

◆ __LOG_INFO__

#define __LOG_INFO__   2

log level Info

Definition at line 9 of file logger.h.

◆ __LOG_TRACE__

#define __LOG_TRACE__   4

log level Trace

Definition at line 11 of file logger.h.

◆ __LOG_WARN__

#define __LOG_WARN__   1

log level Warn

Definition at line 8 of file logger.h.

◆ COMMON_MODULE

#define COMMON_MODULE   1

Definition at line 15 of file logger.h.

◆ LOG_DEBUG

#define LOG_DEBUG (   mod,
  fmt,
  args... 
)    app_log(mod, __LOG_DEBUG__, NULL, fmt, ##args)

Definition at line 20 of file logger.h.

◆ LOG_ERROR

#define LOG_ERROR (   mod,
  fmt,
  args... 
)    app_log(mod, __LOG_ERROR__, NULL, fmt, ##args)

Definition at line 17 of file logger.h.

◆ LOG_INFO

#define LOG_INFO (   mod,
  fmt,
  args... 
)    app_log(mod, __LOG_INFO__, NULL, fmt, ##args)

Definition at line 19 of file logger.h.

◆ LOG_TRACE_IN

#define LOG_TRACE_IN (   mod,
  fmt,
  args... 
)    app_log(mod, __LOG_TRACE__, NULL, "[++%s:%4d]" fmt"\n", __func__, __LINE__, ##args)

Definition at line 21 of file logger.h.

◆ LOG_TRACE_OUT

#define LOG_TRACE_OUT (   mod,
  fmt,
  args... 
)    app_log(mod, __LOG_TRACE__, NULL, "[--%s:%4d]" fmt"\n", __func__, __LINE__, ##args)

Definition at line 22 of file logger.h.

◆ LOG_WARN

#define LOG_WARN (   mod,
  fmt,
  args... 
)    app_log(mod, __LOG_WARN__, NULL, fmt, ##args)

Definition at line 18 of file logger.h.

◆ MAX_LOG_LEVELS

#define MAX_LOG_LEVELS   5

Definition at line 13 of file logger.h.

◆ MAX_MODULES

#define MAX_MODULES   4

Definition at line 14 of file logger.h.

Function Documentation

◆ app_log()

int app_log ( char *  module,
int  level,
char *  prefix,
const char *  format,
  ... 
)


Used for defining different logging modules such as warn, error, debug, trace ...

Returns
- NA

Definition at line 33 of file logger.c.

◆ logger_init()

void logger_init ( )


Initailize logger module

Returns
- NA

Definition at line 17 of file logger.c.