[Libreoffice-commits] online.git: common/Log.hpp

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Feb 13 15:09:41 UTC 2019


 common/Log.hpp |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

New commits:
commit 73b93777f773bc2fc5543ab21562fd0e6bd16bac
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Wed Feb 13 16:08:01 2019 +0100
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Wed Feb 13 16:08:01 2019 +0100

    android: Implement logging to logcat.
    
    Change-Id: I68d7861af019a24d9ecd80782cca38d09485345d

diff --git a/common/Log.hpp b/common/Log.hpp
index bf05fc7ce..f89300110 100644
--- a/common/Log.hpp
+++ b/common/Log.hpp
@@ -24,6 +24,10 @@
 #include <Poco/DateTimeFormatter.h>
 #include <Poco/Logger.h>
 
+#ifdef __ANDROID__
+#include <android/log.h>
+#endif
+
 #include "Util.hpp"
 
 inline std::ostream& operator<< (std::ostream& os, const Poco::Timestamp& ts)
@@ -240,6 +244,17 @@ namespace Log
             LOG << "| " << LOG_FILE_NAME(__FILE__) << ':' << __LINE__; \
     } while (false)
 
+#ifdef __ANDROID__
+
+#define LOG_BODY_(LOG, PRIO, LVL, X, FILEP)                                                 \
+    char b_[1024];                                                                          \
+    std::ostringstream oss_(Log::prefix(b_, sizeof(b_) - 1, LVL), std::ostringstream::ate); \
+    oss_ << std::boolalpha << X;                                                            \
+    LOG_END(oss_, FILEP);                                                                   \
+    ((void)__android_log_print(ANDROID_LOG_DEBUG, "libreoffice", "%s %s", LVL, oss_.str().c_str()))
+
+#else
+
 #define LOG_BODY_(LOG, PRIO, LVL, X, FILEP)                                                 \
     Poco::Message m_(LOG.name(), "", Poco::Message::PRIO_##PRIO);                           \
     char b_[1024];                                                                          \
@@ -249,6 +264,8 @@ namespace Log
     m_.setText(oss_.str());                                                                 \
     LOG.log(m_);
 
+#endif
+
 #define LOG_TRC(X)                                  \
     do                                              \
     {                                               \


More information about the Libreoffice-commits mailing list