10 #ifndef INCLUDED_SAL_DETAIL_LOG_H
11 #define INCLUDED_SAL_DETAIL_LOG_H
37 #if defined __cplusplus
45 #if defined __cplusplus
46 #define SAL_LOG_TRUE true
47 #define SAL_LOG_FALSE false
49 #define SAL_LOG_TRUE sal_True
50 #define SAL_LOG_FALSE sal_False
53 enum sal_detail_LogLevel {
54 SAL_DETAIL_LOG_LEVEL_INFO, SAL_DETAIL_LOG_LEVEL_WARN,
59 enum sal_detail_LogLevel level,
char const * area,
char const * where,
60 char const * format, ...)
62 __attribute__((format(printf, 4, 5)))
66 #if defined __cplusplus
70 #define SAL_DETAIL_LOG_FORMAT(condition, level, area, where, ...) \
73 sal_detail_logFormat((level), (area), (where), __VA_ARGS__); \
75 } while (SAL_LOG_FALSE)
77 #if defined SAL_LOG_INFO
78 #define SAL_DETAIL_ENABLE_LOG_INFO SAL_LOG_TRUE
80 #define SAL_DETAIL_ENABLE_LOG_INFO SAL_LOG_FALSE
82 #if defined SAL_LOG_WARN
83 #define SAL_DETAIL_ENABLE_LOG_WARN SAL_LOG_TRUE
85 #define SAL_DETAIL_ENABLE_LOG_WARN SAL_LOG_FALSE
88 #define SAL_DETAIL_WHERE __FILE__ ":" SAL_STRINGIFY(__LINE__) ": "
90 #define SAL_DETAIL_INFO_IF_FORMAT(condition, area, ...) \
91 SAL_DETAIL_LOG_FORMAT( \
92 SAL_DETAIL_ENABLE_LOG_INFO && (condition), SAL_DETAIL_LOG_LEVEL_INFO, \
93 area, SAL_DETAIL_WHERE, __VA_ARGS__)
95 #define SAL_DETAIL_WARN_IF_FORMAT(condition, area, ...) \
96 SAL_DETAIL_LOG_FORMAT( \
97 SAL_DETAIL_ENABLE_LOG_WARN && (condition), SAL_DETAIL_LOG_LEVEL_WARN, \
98 area, SAL_DETAIL_WHERE, __VA_ARGS__)