10 #ifndef INCLUDED_SAL_LOG_HXX
11 #define INCLUDED_SAL_LOG_HXX
30 sal_detail_LogLevel level,
char const * area,
char const * where,
31 char const * message, sal_uInt32 backtraceDepth);
34 sal_detail_LogLevel level,
char const * area);
36 namespace sal {
namespace detail {
39 sal_detail_LogLevel level,
char const * area,
char const * where,
40 std::ostringstream
const & stream, sal_uInt32 backtraceDepth)
50 sal_detail_log(level, area, where, stream.str().c_str(), backtraceDepth);
56 struct StreamStart {};
59 StreamString(
char const * s): string(s) {}
67 typedef struct {
char a[2]; } Result;
73 return StreamString(s);
76 template<
typename T >
inline StreamIgnore
operator <<(
80 #if defined _MSC_VER && _MSC_VER < 1700
81 return StreamIgnore();
85 template<
typename T >
inline StreamIgnore
operator <<(
89 #if defined _MSC_VER && _MSC_VER < 1700
90 return StreamIgnore();
94 template<
typename T >
inline StreamIgnore
operator <<(
98 #if defined _MSC_VER && _MSC_VER < 1700
99 return StreamIgnore();
103 template<
typename T >
typename T::Result getResult(T
const &);
105 inline char const * unwrapStream(StreamString
const & s) {
return s.string; }
109 #if defined _MSC_VER && _MSC_VER < 1700
116 #define SAL_DETAIL_LOG_STREAM(condition, level, area, where, stream) \
118 if ((condition) && sal_detail_log_report(level, area)) { \
119 if (sizeof ::sal::detail::getResult( \
120 ::sal::detail::StreamStart() << stream) == 1) \
123 (level), (area), (where), \
124 ::sal::detail::unwrapStream( \
125 ::sal::detail::StreamStart() << stream), \
128 ::std::ostringstream sal_detail_stream; \
129 sal_detail_stream << stream; \
130 ::sal::detail::log( \
131 (level), (area), (where), sal_detail_stream, 0); \
148 #define SAL_WHERE SAL_DETAIL_WHERE
164 #ifdef _LIBCPP_VERSION
165 #define SAL_STREAM(stream) \
166 (::std::ostringstream() << stream).str()
168 #define SAL_STREAM(stream) \
169 (dynamic_cast< ::std::ostringstream & >(::std::ostringstream() << stream).str())
297 #define SAL_INFO(area, stream) \
298 SAL_DETAIL_LOG_STREAM( \
299 SAL_DETAIL_ENABLE_LOG_INFO, ::SAL_DETAIL_LOG_LEVEL_INFO, area, \
307 #define SAL_INFO_IF(condition, area, stream) \
308 SAL_DETAIL_LOG_STREAM( \
309 SAL_DETAIL_ENABLE_LOG_INFO && (condition), \
310 ::SAL_DETAIL_LOG_LEVEL_INFO, area, SAL_WHERE, stream)
317 #define SAL_WARN(area, stream) \
318 SAL_DETAIL_LOG_STREAM( \
319 SAL_DETAIL_ENABLE_LOG_WARN, ::SAL_DETAIL_LOG_LEVEL_WARN, area, \
327 #define SAL_WARN_IF(condition, area, stream) \
328 SAL_DETAIL_LOG_STREAM( \
329 SAL_DETAIL_ENABLE_LOG_WARN && (condition), \
330 ::SAL_DETAIL_LOG_LEVEL_WARN, area, SAL_WHERE, stream)
338 #define SAL_DEBUG(stream) \
339 SAL_DETAIL_LOG_STREAM( \
340 SAL_LOG_TRUE, ::SAL_DETAIL_LOG_LEVEL_DEBUG, NULL, NULL, stream)
356 #define SAL_DEBUG_BACKTRACE(stream, backtraceDepth) \
358 if (sizeof ::sal::detail::getResult( \
359 ::sal::detail::StreamStart() << stream) == 1) \
362 ::SAL_DETAIL_LOG_LEVEL_DEBUG, NULL, NULL, \
363 ::sal::detail::unwrapStream( \
364 ::sal::detail::StreamStart() << stream), \
367 ::std::ostringstream sal_detail_stream; \
368 sal_detail_stream << stream; \
369 ::sal::detail::log( \
370 ::SAL_DETAIL_LOG_LEVEL_DEBUG, NULL, NULL, sal_detail_stream, \