diff options
author | Jan Holesovsky <kendy@collabora.com> | 2019-02-13 16:08:01 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2019-02-13 16:08:01 +0100 |
commit | 73b93777f773bc2fc5543ab21562fd0e6bd16bac (patch) | |
tree | 5c8bc7ec1d46068bada438b6f60f4e5b6fd8ce94 | |
parent | dc37e633efd7bf61072f7c3804d23928249f97e2 (diff) |
android: Implement logging to logcat.
Change-Id: I68d7861af019a24d9ecd80782cca38d09485345d
-rw-r--r-- | common/Log.hpp | 17 |
1 files changed, 17 insertions, 0 deletions
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 \ { \ |