reactor-c
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
logging_macros.h
Go to the documentation of this file.
1
#ifndef LOGGING_MACROS_H
2
#define LOGGING_MACROS_H
3
#include "
logging.h
"
4
13
#ifndef LOG_LEVEL
14
#define LOG_LEVEL LOG_LEVEL_INFO
15
#endif
16
17
// To prevent warnings "conditional expression is constant", we define static booleans
18
// here instead of directly testing LOG_LEVEL in the if statements in the macros below.
19
static
const
bool
_lf_log_level_is_log =
LOG_LEVEL
>=
LOG_LEVEL_LOG
;
20
static
const
bool
_lf_log_level_is_debug =
LOG_LEVEL
>=
LOG_LEVEL_DEBUG
;
21
39
#define LF_PRINT_LOG(format, ...) \
40
do { \
41
if (_lf_log_level_is_log) { \
42
lf_print_log(format, ##__VA_ARGS__); \
43
} \
44
} while (0)
45
62
#define LF_PRINT_DEBUG(format, ...) \
63
do { \
64
if (_lf_log_level_is_debug) { \
65
lf_print_debug(format, ##__VA_ARGS__); \
66
} \
67
} while (0)
68
83
#if defined(NDEBUG)
84
#define LF_ASSERT(condition, format, ...) (void)(condition)
85
#define LF_ASSERTN(condition, format, ...) (void)(condition)
86
#define LF_ASSERT_NON_NULL(pointer) (void)(pointer)
87
#else
88
#define LF_ASSERT(condition, format, ...) \
89
do { \
90
if (!(condition)) { \
91
lf_print_error_and_exit("`" format "`. Failed assertion in %s:%d(%s):(" #condition ") != true`", ##__VA_ARGS__, \
92
__FILE__, __LINE__, __func__); \
93
} \
94
} while (0)
95
#define LF_ASSERTN(condition, format, ...) \
96
do { \
97
if (condition) { \
98
lf_print_error_and_exit("`" format "`. Failed assertion in %s:%d(%s):(" #condition ") != false`", ##__VA_ARGS__, \
99
__FILE__, __LINE__, __func__); \
100
} \
101
} while (0)
102
#define LF_ASSERT_NON_NULL(pointer) \
103
do { \
104
if (!(pointer)) { \
105
lf_print_error_and_exit("`Out of memory?` Assertion failed in %s:%d(%s):`" #pointer " == NULL`", __FILE__, \
106
__LINE__, __func__); \
107
} \
108
} while (0)
109
#endif
// NDEBUG
110
#endif
// LOGGING_MACROS_H
logging.h
LOG_LEVEL_DEBUG
#define LOG_LEVEL_DEBUG
Definition
logging.h:28
LOG_LEVEL_LOG
#define LOG_LEVEL_LOG
Definition
logging.h:27
LOG_LEVEL
#define LOG_LEVEL
Definition
logging_macros.h:14
logging
api
logging_macros.h
Generated by
1.12.0