Fork me on GitHub
Variables
debug.h File Reference

Logging and Debugging. More...

#include <glib.h>
#include <glib/gprintf.h>
#include "log.h"
Include dependency graph for debug.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

Janus log colors
#define ANSI_COLOR_RED   "\x1b[31m"
 
#define ANSI_COLOR_GREEN   "\x1b[32m"
 
#define ANSI_COLOR_YELLOW   "\x1b[33m"
 
#define ANSI_COLOR_BLUE   "\x1b[34m"
 
#define ANSI_COLOR_MAGENTA   "\x1b[35m"
 
#define ANSI_COLOR_CYAN   "\x1b[36m"
 
#define ANSI_COLOR_RESET   "\x1b[0m"
 
Janus log wrappers
#define JANUS_PRINT   janus_vprintf
 Simple wrapper to g_print/printf. More...
 
#define JANUS_LOG(level, format, ...)
 Logger based on different levels, which can either be displayed or not according to the configuration of the server. The format must be a string literal. More...
 

Variables

int janus_log_level
 
gboolean janus_log_timestamps
 
gboolean janus_log_colors
 

Janus log levels

#define LOG_NONE   (0)
 No debugging. More...
 
#define LOG_FATAL   (1)
 Fatal error. More...
 
#define LOG_ERR   (2)
 Non-fatal error. More...
 
#define LOG_WARN   (3)
 Warning. More...
 
#define LOG_INFO   (4)
 Informational message. More...
 
#define LOG_VERB   (5)
 Verbose message. More...
 
#define LOG_HUGE   (6)
 Overly verbose message. More...
 
#define LOG_DBG   (7)
 Debug message (includes .c filename, function and line number) More...
 
#define LOG_MAX   LOG_DBG
 Maximum level of debugging. More...
 

Detailed Description

Logging and Debugging.

Author
Lorenzo Miniero loren.nosp@m.zo@m.nosp@m.eetec.nosp@m.ho.c.nosp@m.om

Implementation of a wrapper on printf (or g_print) to either log or debug.

Todo:
Improve this wrappers to optionally save logs on file

Core

Macro Definition Documentation

#define ANSI_COLOR_BLUE   "\x1b[34m"
#define ANSI_COLOR_CYAN   "\x1b[36m"
#define ANSI_COLOR_GREEN   "\x1b[32m"
#define ANSI_COLOR_MAGENTA   "\x1b[35m"
#define ANSI_COLOR_RED   "\x1b[31m"
#define ANSI_COLOR_RESET   "\x1b[0m"
#define ANSI_COLOR_YELLOW   "\x1b[33m"
#define JANUS_LOG (   level,
  format,
  ... 
)
Value:
do { \
if (level > LOG_NONE && level <= LOG_MAX && level <= janus_log_level) { \
char janus_log_ts[64] = ""; \
char janus_log_src[128] = ""; \
struct tm janustmresult; \
time_t janusltime = time(NULL); \
localtime_r(&janusltime, &janustmresult); \
strftime(janus_log_ts, sizeof(janus_log_ts), \
"[%a %b %e %T %Y] ", &janustmresult); \
} \
if (level == LOG_FATAL || level == LOG_ERR || level == LOG_DBG) { \
snprintf(janus_log_src, sizeof(janus_log_src), \
"[%s:%s:%d] ", __FILE__, __FUNCTION__, __LINE__); \
} \
JANUS_PRINT("%s%s%s" format, \
janus_log_ts, \
janus_log_prefix[level | ((int)janus_log_colors << 3)], \
janus_log_src, \
##__VA_ARGS__); \
} \
} while (0)
gboolean janus_log_colors
Definition: janus.c:333
#define JANUS_PRINT
Simple wrapper to g_print/printf.
Definition: debug.h:84
int janus_log_level
Definition: janus.c:331
#define LOG_ERR
Non-fatal error.
Definition: debug.h:43
#define LOG_NONE
No debugging.
Definition: debug.h:39
gboolean janus_log_timestamps
Definition: janus.c:332
#define LOG_MAX
Maximum level of debugging.
Definition: debug.h:55
#define LOG_FATAL
Fatal error.
Definition: debug.h:41
#define LOG_DBG
Debug message (includes .c filename, function and line number)
Definition: debug.h:53

Logger based on different levels, which can either be displayed or not according to the configuration of the server. The format must be a string literal.

#define JANUS_PRINT   janus_vprintf

Simple wrapper to g_print/printf.

#define LOG_DBG   (7)

Debug message (includes .c filename, function and line number)

#define LOG_ERR   (2)

Non-fatal error.

#define LOG_FATAL   (1)

Fatal error.

#define LOG_HUGE   (6)

Overly verbose message.

#define LOG_INFO   (4)

Informational message.

#define LOG_MAX   LOG_DBG

Maximum level of debugging.

#define LOG_NONE   (0)

No debugging.

#define LOG_VERB   (5)

Verbose message.

#define LOG_WARN   (3)

Warning.

Variable Documentation

gboolean janus_log_colors
int janus_log_level
gboolean janus_log_timestamps