[Libreoffice-commits] core.git: include/sal sal/osl

Stephan Bergmann sbergman at redhat.com
Thu Feb 9 16:08:11 UTC 2017


 include/sal/log.hxx |    6 +++---
 sal/osl/all/log.cxx |   28 +++++++---------------------
 2 files changed, 10 insertions(+), 24 deletions(-)

New commits:
commit c697ae306cd4eaa8144ed93fc908e50d5934e249
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Feb 9 17:05:22 2017 +0100

    Some clean up
    
    No more need to call sal_detail_log_report from sal_detail_log, now that it is
    called from SAL_DETAIL_LOG_STREAM since b3a11c8f4f307bbbb597c9c6e7e61ee93e794873
    "tdf#91872: Make SAL_INFO and friends more efficient".
    
    Change-Id: Idb6cf7a4814abe29d5ba68591f39b4279267bc9b

diff --git a/include/sal/log.hxx b/include/sal/log.hxx
index a21f80b..c096d52 100644
--- a/include/sal/log.hxx
+++ b/include/sal/log.hxx
@@ -27,11 +27,11 @@
 /// @cond INTERNAL
 
 extern "C" SAL_DLLPUBLIC void SAL_CALL sal_detail_log(
-    enum sal_detail_LogLevel level, char const * area, char const * where,
+    sal_detail_LogLevel level, char const * area, char const * where,
     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);
+extern "C" SAL_DLLPUBLIC sal_Bool SAL_CALL sal_detail_log_report(
+    sal_detail_LogLevel level, char const * area);
 
 namespace sal { namespace detail {
 
diff --git a/sal/osl/all/log.cxx b/sal/osl/all/log.cxx
index 774e7e8..0e15aab 100644
--- a/sal/osl/all/log.cxx
+++ b/sal/osl/all/log.cxx
@@ -186,11 +186,9 @@ void maybeOutputTimestamp(std::ostringstream &s) {
 
 #endif
 
-bool isDebug(sal_detail_LogLevel level) {
-    return level == SAL_DETAIL_LOG_LEVEL_DEBUG;
 }
 
-void log(
+void sal_detail_log(
     sal_detail_LogLevel level, char const * area, char const * where,
     char const * message, sal_uInt32 backtraceDepth)
 {
@@ -202,13 +200,13 @@ void log(
         maybeOutputTimestamp(s);
         s << toString(level) << ':';
     }
-    if (!isDebug(level)) {
+    if (level != SAL_DETAIL_LOG_LEVEL_DEBUG) {
         s << area << ':';
     }
     s << OSL_DETAIL_GETPID << ':';
 #endif
     s << osl::Thread::getCurrentIdentifier() << ':';
-    if (isDebug(level)) {
+    if (level == SAL_DETAIL_LOG_LEVEL_DEBUG) {
         s << ' ';
     } else {
         const size_t nStrLen(std::strlen(SRCDIR "/"));
@@ -216,13 +214,11 @@ void log(
               + (std::strncmp(where, SRCDIR "/", nStrLen) == 0
                  ? nStrLen : 0));
     }
-
     s << message;
     if (backtraceDepth != 0) {
         s << " at:\n" << osl::detail::backtraceAsString(backtraceDepth);
     }
     s << '\n';
-
 #if defined ANDROID
     int android_log_level;
     switch (level) {
@@ -276,17 +272,6 @@ void log(
 #endif
 }
 
-}
-
-void sal_detail_log(
-    sal_detail_LogLevel level, char const * area, char const * where,
-    char const * message, sal_uInt32 backtraceDepth)
-{
-    if (sal_detail_log_report(level, area)) {
-        log(level, area, where, message, backtraceDepth);
-    }
-}
-
 void sal_detail_logFormat(
     sal_detail_LogLevel level, char const * area, char const * where,
     char const * format, ...)
@@ -302,14 +287,15 @@ void sal_detail_logFormat(
         } else if (n >= len) {
             std::strcpy(buf + len - 1, "...");
         }
-        log(level, area, where, buf, 0);
+        sal_detail_log(level, area, where, buf, 0);
         va_end(args);
     }
 }
 
-int sal_detail_log_report(enum sal_detail_LogLevel level, char const * area) {
-    if (isDebug(level))
+sal_Bool sal_detail_log_report(sal_detail_LogLevel level, char const * area) {
+    if (level == SAL_DETAIL_LOG_LEVEL_DEBUG) {
         return true;
+    }
     assert(area != nullptr);
     char const * env = getEnvironmentVariable();
     if (env == nullptr) {


More information about the Libreoffice-commits mailing list