00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef INCLUDED_SAL_DETAIL_LOG_H
00031 #define INCLUDED_SAL_DETAIL_LOG_H
00032
00033 #include "sal/config.h"
00034
00035 #include "sal/saldllapi.h"
00036 #include "sal/types.h"
00037
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 #if defined __cplusplus
00059 extern "C" {
00060 #endif
00061
00062
00063
00064
00065
00066 #if defined __cplusplus
00067 #define SAL_LOG_TRUE true
00068 #define SAL_LOG_FALSE false
00069 #else
00070 #define SAL_LOG_TRUE sal_True
00071 #define SAL_LOG_FALSE sal_False
00072 #endif
00073
00074 enum sal_detail_LogLevel {
00075 SAL_DETAIL_LOG_LEVEL_INFO, SAL_DETAIL_LOG_LEVEL_WARN,
00076 SAL_DETAIL_LOG_LEVEL_DEBUG = SAL_MAX_ENUM
00077 };
00078
00079 SAL_DLLPUBLIC void SAL_CALL sal_detail_logFormat(
00080 enum sal_detail_LogLevel level, char const * area, char const * where,
00081 char const * format, ...)
00082
00083 #if defined GCC && 0
00084 __attribute__((format(printf, 4, 5)))
00085 #endif
00086 ;
00087
00088 #if defined __cplusplus
00089 }
00090 #endif
00091
00092 #define SAL_DETAIL_LOG_FORMAT(condition, level, area, where, ...) \
00093 do { \
00094 if (condition) { \
00095 sal_detail_logFormat((level), (area), (where), __VA_ARGS__); \
00096 } \
00097 } while (SAL_LOG_FALSE)
00098
00099 #if defined SAL_LOG_INFO
00100 #define SAL_DETAIL_ENABLE_LOG_INFO SAL_LOG_TRUE
00101 #else
00102 #define SAL_DETAIL_ENABLE_LOG_INFO SAL_LOG_FALSE
00103 #endif
00104 #if defined SAL_LOG_WARN
00105 #define SAL_DETAIL_ENABLE_LOG_WARN SAL_LOG_TRUE
00106 #else
00107 #define SAL_DETAIL_ENABLE_LOG_WARN SAL_LOG_FALSE
00108 #endif
00109
00110 #define SAL_DETAIL_WHERE __FILE__ ":" SAL_STRINGIFY(__LINE__) ": "
00111
00112 #define SAL_DETAIL_INFO_IF_FORMAT(condition, area, ...) \
00113 SAL_DETAIL_LOG_FORMAT( \
00114 SAL_DETAIL_ENABLE_LOG_INFO && (condition), SAL_DETAIL_LOG_LEVEL_INFO, \
00115 area, SAL_DETAIL_WHERE, __VA_ARGS__)
00116
00117 #define SAL_DETAIL_WARN_IF_FORMAT(condition, area, ...) \
00118 SAL_DETAIL_LOG_FORMAT( \
00119 SAL_DETAIL_ENABLE_LOG_WARN && (condition), SAL_DETAIL_LOG_LEVEL_WARN, \
00120 area, SAL_DETAIL_WHERE, __VA_ARGS__)
00121
00124 #endif
00125
00126