Loading...
Searching...
No Matches
debug.h File Reference
Core

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.
#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.

## Variables

int | janus_log_level
gboolean | janus_log_timestamps
gboolean | janus_log_colors
char * | janus_log_global_prefix

## Janus log levels

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

## Detailed Description

Logging and Debugging.

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

Copyright
  GNU General Public License v3

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

Core

## Macro Definition Documentation

## ANSI_COLOR_BLUE

#define ANSI_COLOR_BLUE "\x1b[34m"

## ANSI_COLOR_CYAN

#define ANSI_COLOR_CYAN "\x1b[36m"

## ANSI_COLOR_GREEN

#define ANSI_COLOR_GREEN "\x1b[32m"

## ANSI_COLOR_MAGENTA

#define ANSI_COLOR_MAGENTA "\x1b[35m"

## ANSI_COLOR_RED

#define ANSI_COLOR_RED "\x1b[31m"

## ANSI_COLOR_RESET

#define ANSI_COLOR_RESET "\x1b[0m"

## ANSI_COLOR_YELLOW

#define ANSI_COLOR_YELLOW "\x1b[33m"

## JANUS_LOG

#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] = ""; \
if (janus_log_timestamps) { \
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%s" format, \
janus_log_global_prefix ? janus_log_global_prefix : "", \
janus_log_ts, \
janus_log_prefix[level | ((int)janus_log_colors << 3)], \
janus_log_src, \
##__VA_ARGS__); \
} \
} while (0)
janus_log_level
int janus_log_level
Definition janus-cfgconv.c:34
janus_log_timestamps
gboolean janus_log_timestamps
Definition janus-cfgconv.c:35
LOG_NONE
#define LOG_NONE
No debugging.
Definition debug.h:39
LOG_DBG
#define LOG_DBG
Debug message (includes .c filename, function and line number).
Definition debug.h:53
LOG_ERR
#define LOG_ERR
Non-fatal error.
Definition debug.h:43
LOG_FATAL
#define LOG_FATAL
Fatal error.
Definition debug.h:41
janus_log_colors
gboolean janus_log_colors
Definition janus-cfgconv.c:36
LOG_MAX
#define LOG_MAX
Maximum level of debugging.
Definition debug.h:55
janus_log_global_prefix
char * janus_log_global_prefix
Definition janus-cfgconv.c:37

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.

## JANUS_PRINT

#define JANUS_PRINT janus_vprintf

Simple wrapper to g_print/printf.

## LOG_DBG

#define LOG_DBG (7)

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

## LOG_ERR

#define LOG_ERR (2)

Non-fatal error.

## LOG_FATAL

#define LOG_FATAL (1)

Fatal error.

## LOG_HUGE

#define LOG_HUGE (6)

Overly verbose message.

## LOG_INFO

#define LOG_INFO (4)

Informational message.

## LOG_MAX

#define LOG_MAX LOG_DBG

Maximum level of debugging.

## LOG_NONE

#define LOG_NONE (0)

No debugging.

## LOG_VERB

#define LOG_VERB (5)

Verbose message.

## LOG_WARN

#define LOG_WARN (3)

Warning.

## Variable Documentation

## janus_log_colors

gboolean janus_log_colors

extern

## janus_log_global_prefix

char* janus_log_global_prefix

extern

## janus_log_level

int janus_log_level

extern

## janus_log_timestamps

gboolean janus_log_timestamps

extern