aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/log.h
blob: f1ee63a4e25ea7ae3da6fde83b5025b7ccc30efd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef NVIM_LOG_H
#define NVIM_LOG_H

#include <stdbool.h>

#define DEBUG_LOG_LEVEL 0
#define INFO_LOG_LEVEL 1
#define WARNING_LOG_LEVEL 2
#define ERROR_LOG_LEVEL 3

#define DLOG(...)
#define ILOG(...)
#define WLOG(...)
#define ELOG(...)

// Logging is disabled if NDEBUG or DISABLE_LOG is defined.
#ifdef NDEBUG
#  define DISABLE_LOG
#endif

// MIN_LOG_LEVEL can be defined during compilation to adjust the desired level
// of logging. INFO_LOG_LEVEL is used by default.
#ifndef MIN_LOG_LEVEL
#  define MIN_LOG_LEVEL INFO_LOG_LEVEL
#endif

#ifndef DISABLE_LOG

#  if MIN_LOG_LEVEL <= DEBUG_LOG_LEVEL
#    undef DLOG
#    define DLOG(...) do_log(DEBUG_LOG_LEVEL, __func__, __LINE__, __VA_ARGS__)
#  endif

#  if MIN_LOG_LEVEL <= INFO_LOG_LEVEL
#    undef ILOG
#    define ILOG(...) do_log(INFO_LOG_LEVEL, __func__, __LINE__, __VA_ARGS__)
#  endif

#  if MIN_LOG_LEVEL <= WARNING_LOG_LEVEL
#    undef WLOG
#    define WLOG(...) do_log(WARNING_LOG_LEVEL, __func__, __LINE__, __VA_ARGS__)
#  endif

#  if MIN_LOG_LEVEL <= ERROR_LOG_LEVEL
#    undef ELOG
#    define ELOG(...) do_log(ERROR_LOG_LEVEL, __func__, __LINE__, __VA_ARGS__)
#  endif

#endif

#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "log.h.generated.h"
#endif
#endif  // NVIM_LOG_H