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 #if defined _LIBCPP_VERSION || (defined _MSC_VER && _MSC_VER >= 1915)
165 #define SAL_STREAM(stream) \
166 (::std::ostringstream() << stream).str()
168 #define SAL_STREAM(stream) \
169 (dynamic_cast< ::std::ostringstream & >(::std::ostringstream() << stream).str())
303 #define SAL_INFO(area, stream) \
304 SAL_DETAIL_LOG_STREAM( \
305 SAL_DETAIL_ENABLE_LOG_INFO, ::SAL_DETAIL_LOG_LEVEL_INFO, area, \
313 #define SAL_INFO_IF(condition, area, stream) \
314 SAL_DETAIL_LOG_STREAM( \
315 SAL_DETAIL_ENABLE_LOG_INFO && (condition), \
316 ::SAL_DETAIL_LOG_LEVEL_INFO, area, SAL_WHERE, stream)
323 #define SAL_WARN(area, stream) \
324 SAL_DETAIL_LOG_STREAM( \
325 SAL_DETAIL_ENABLE_LOG_WARN, ::SAL_DETAIL_LOG_LEVEL_WARN, area, \
333 #define SAL_WARN_IF(condition, area, stream) \
334 SAL_DETAIL_LOG_STREAM( \
335 SAL_DETAIL_ENABLE_LOG_WARN && (condition), \
336 ::SAL_DETAIL_LOG_LEVEL_WARN, area, SAL_WHERE, stream)
344 #define SAL_DEBUG(stream) \
345 SAL_DETAIL_LOG_STREAM( \
346 SAL_LOG_TRUE, ::SAL_DETAIL_LOG_LEVEL_DEBUG, NULL, NULL, stream)
362 #define SAL_DEBUG_BACKTRACE(stream, backtraceDepth) \
364 if (sizeof ::sal::detail::getResult( \
365 ::sal::detail::StreamStart() << stream) == 1) \
368 ::SAL_DETAIL_LOG_LEVEL_DEBUG, NULL, NULL, \
369 ::sal::detail::unwrapStream( \
370 ::sal::detail::StreamStart() << stream), \
373 ::std::ostringstream sal_detail_stream; \
374 sal_detail_stream << stream; \
375 ::sal::detail::log( \
376 ::SAL_DETAIL_LOG_LEVEL_DEBUG, NULL, NULL, sal_detail_stream, \