30 #ifndef INCLUDED_SAL_DETAIL_LOG_H
31 #define INCLUDED_SAL_DETAIL_LOG_H
58 #if defined __cplusplus
66 #if defined __cplusplus
67 #define SAL_LOG_TRUE true
68 #define SAL_LOG_FALSE false
70 #define SAL_LOG_TRUE sal_True
71 #define SAL_LOG_FALSE sal_False
74 enum sal_detail_LogLevel {
75 SAL_DETAIL_LOG_LEVEL_INFO, SAL_DETAIL_LOG_LEVEL_WARN,
76 SAL_DETAIL_LOG_LEVEL_DEBUG = SAL_MAX_ENUM
80 enum sal_detail_LogLevel level,
char const * area,
char const * where,
81 char const * format, ...)
84 __attribute__((format(printf, 4, 5)))
88 #if defined __cplusplus
92 #define SAL_DETAIL_LOG_FORMAT(condition, level, area, where, ...) \
95 sal_detail_logFormat((level), (area), (where), __VA_ARGS__); \
97 } while (SAL_LOG_FALSE)
99 #if defined SAL_LOG_INFO
100 #define SAL_DETAIL_ENABLE_LOG_INFO SAL_LOG_TRUE
102 #define SAL_DETAIL_ENABLE_LOG_INFO SAL_LOG_FALSE
104 #if defined SAL_LOG_WARN
105 #define SAL_DETAIL_ENABLE_LOG_WARN SAL_LOG_TRUE
107 #define SAL_DETAIL_ENABLE_LOG_WARN SAL_LOG_FALSE
110 #define SAL_DETAIL_WHERE __FILE__ ":" SAL_STRINGIFY(__LINE__) ": "
112 #define SAL_DETAIL_INFO_IF_FORMAT(condition, area, ...) \
113 SAL_DETAIL_LOG_FORMAT( \
114 SAL_DETAIL_ENABLE_LOG_INFO && (condition), SAL_DETAIL_LOG_LEVEL_INFO, \
115 area, SAL_DETAIL_WHERE, __VA_ARGS__)
117 #define SAL_DETAIL_WARN_IF_FORMAT(condition, area, ...) \
118 SAL_DETAIL_LOG_FORMAT( \
119 SAL_DETAIL_ENABLE_LOG_WARN && (condition), SAL_DETAIL_LOG_LEVEL_WARN, \
120 area, SAL_DETAIL_WHERE, __VA_ARGS__)