30 #ifndef INCLUDED_SAL_DETAIL_LOG_H
31 #define INCLUDED_SAL_DETAIL_LOG_H
57 #if defined __cplusplus
65 #if defined __cplusplus
66 #define SAL_LOG_TRUE true
67 #define SAL_LOG_FALSE false
69 #define SAL_LOG_TRUE sal_True
70 #define SAL_LOG_FALSE sal_False
73 enum sal_detail_LogLevel {
74 SAL_DETAIL_LOG_LEVEL_INFO, SAL_DETAIL_LOG_LEVEL_WARN,
75 SAL_DETAIL_LOG_LEVEL_DEBUG = SAL_MAX_ENUM
79 enum sal_detail_LogLevel level,
char const * area,
char const * where,
80 char const * format, ...)
83 __attribute__((format(printf, 4, 5)))
87 #if defined __cplusplus
91 #define SAL_DETAIL_LOG_FORMAT(condition, level, area, where, ...) \
94 sal_detail_logFormat((level), (area), (where), __VA_ARGS__); \
96 } while (SAL_LOG_FALSE)
98 #if defined SAL_LOG_INFO
99 #define SAL_DETAIL_ENABLE_LOG_INFO SAL_LOG_TRUE
101 #define SAL_DETAIL_ENABLE_LOG_INFO SAL_LOG_FALSE
103 #if defined SAL_LOG_WARN
104 #define SAL_DETAIL_ENABLE_LOG_WARN SAL_LOG_TRUE
106 #define SAL_DETAIL_ENABLE_LOG_WARN SAL_LOG_FALSE
109 #define SAL_DETAIL_WHERE __FILE__ ":" SAL_STRINGIFY(__LINE__) ": "
111 #define SAL_DETAIL_INFO_IF_FORMAT(condition, area, ...) \
112 SAL_DETAIL_LOG_FORMAT( \
113 SAL_DETAIL_ENABLE_LOG_INFO && (condition), SAL_DETAIL_LOG_LEVEL_INFO, \
114 area, SAL_DETAIL_WHERE, __VA_ARGS__)
116 #define SAL_DETAIL_WARN_IF_FORMAT(condition, area, ...) \
117 SAL_DETAIL_LOG_FORMAT( \
118 SAL_DETAIL_ENABLE_LOG_WARN && (condition), SAL_DETAIL_LOG_LEVEL_WARN, \
119 area, SAL_DETAIL_WHERE, __VA_ARGS__)