diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-02-09 13:19:11 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-02-09 15:56:50 +0000 |
commit | b6a69585b00867005820c1dd94e10e0e6b545e2a (patch) | |
tree | 39c76e48dffcfbadd619cf7dc52bb9def0f85691 /include/sal | |
parent | 6851074c8a515ec5a7856d4b744e3425c8829a29 (diff) |
Fold sal_detail_log_backtrace into sal_detail_log
...the latter is LO-privately exported from sal, so it should be OK to add one
more parameter to it.
Change-Id: If6bf3458433aac2cc8b4e0cbd1602306051a777b
Reviewed-on: https://gerrit.libreoffice.org/34080
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/sal')
-rw-r--r-- | include/sal/log.hxx | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/include/sal/log.hxx b/include/sal/log.hxx index b383fd030535..a21f80b7f8d9 100644 --- a/include/sal/log.hxx +++ b/include/sal/log.hxx @@ -28,20 +28,16 @@ extern "C" SAL_DLLPUBLIC void SAL_CALL sal_detail_log( enum sal_detail_LogLevel level, char const * area, char const * where, - char const * message); - -extern "C" SAL_DLLPUBLIC void SAL_CALL sal_detail_log_backtrace( - enum sal_detail_LogLevel level, char const * area, char const * where, - char const * message, int maxNoStackFramesToDisplay); + char const * message, sal_uInt32 backtraceDepth); extern "C" SAL_DLLPUBLIC int SAL_CALL sal_detail_log_report( enum sal_detail_LogLevel level, char const * area); namespace sal { namespace detail { -inline void SAL_CALL log( +inline void log( sal_detail_LogLevel level, char const * area, char const * where, - std::ostringstream const & stream) + std::ostringstream const & stream, sal_uInt32 backtraceDepth) { // An alternative would be to have sal_detail_log take a std::ostringstream // pointer (via a C void pointer); the advantage would be smaller client @@ -51,15 +47,7 @@ inline void SAL_CALL log( // on the C++ ABI; as a compromise, the ".str().c_str()" part has been moved // to this inline function so that it is potentially only emitted once per // dynamic library: - sal_detail_log(level, area, where, stream.str().c_str()); -} - -inline void SAL_CALL log_backtrace( - sal_detail_LogLevel level, char const * area, char const * where, - std::ostringstream const & stream, int maxNoStackFramesToDisplay) -{ - sal_detail_log_backtrace( - level, area, where, stream.str().c_str(), maxNoStackFramesToDisplay); + sal_detail_log(level, area, where, stream.str().c_str(), backtraceDepth); } // Special handling of the common case where the message consists of just a @@ -134,12 +122,13 @@ inline char const * unwrapStream(SAL_UNUSED_PARAMETER StreamIgnore const &) { ::sal_detail_log( \ (level), (area), (where), \ ::sal::detail::unwrapStream( \ - ::sal::detail::StreamStart() << stream)); \ + ::sal::detail::StreamStart() << stream), \ + 0); \ } else { \ ::std::ostringstream sal_detail_stream; \ sal_detail_stream << stream; \ ::sal::detail::log( \ - (level), (area), (where), sal_detail_stream); \ + (level), (area), (where), sal_detail_stream, 0); \ } \ } \ } while (false) @@ -351,28 +340,33 @@ inline char const * unwrapStream(SAL_UNUSED_PARAMETER StreamIgnore const &) { SAL_LOG_TRUE, ::SAL_DETAIL_LOG_LEVEL_DEBUG, NULL, NULL, stream) /** - Produce temporary debugging output from stream along with a - stack trace of the calling location. This macro is meant to - be used only while working on code and should never exist - in production code. + Produce temporary debugging output from stream along with a backtrace of the + calling location. + + This macro is meant to be used only while working on code and should never + exist in production code. + + @param backtraceDepth a sal_uInt32 value indicating the maximum backtrace + depth; zero means no backtrace See @ref sal_log "basic logging functionality" for details. */ -#define SAL_DEBUG_BACKTRACE(stream, maxNoStackFramesToDisplay) \ +#define SAL_DEBUG_BACKTRACE(stream, backtraceDepth) \ do { \ - if (sizeof ::sal::detail::getResult(::sal::detail::StreamStart() << stream) == 1) \ + if (sizeof ::sal::detail::getResult( \ + ::sal::detail::StreamStart() << stream) == 1) \ { \ - ::sal_detail_log_backtrace( \ + ::sal_detail_log( \ ::SAL_DETAIL_LOG_LEVEL_DEBUG, NULL, NULL, \ ::sal::detail::unwrapStream( \ ::sal::detail::StreamStart() << stream), \ - maxNoStackFramesToDisplay); \ + backtraceDepth); \ } else { \ ::std::ostringstream sal_detail_stream; \ sal_detail_stream << stream; \ - ::sal::detail::log_backtrace( \ + ::sal::detail::log( \ ::SAL_DETAIL_LOG_LEVEL_DEBUG, NULL, NULL, sal_detail_stream, \ - maxNoStackFramesToDisplay); \ + backtraceDepth); \ } \ } while (false) |