commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 05/12: android: logger: adding Android log


From: git
Subject: [Commit-gnuradio] [gnuradio] 05/12: android: logger: adding Android log functions for different logging levels.
Date: Fri, 19 Feb 2016 13:58:39 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

trondeau pushed a commit to branch android
in repository gnuradio.

commit 4e1c327d5f0eb96faaa6dff45b17392b2b05607a
Author: Tom Rondeau <address@hidden>
Date:   Sun Dec 21 09:27:35 2014 -0500

    android: logger: adding Android log functions for different logging levels.
    
    GR_X log macros behave the same as normal under Andorid, just using its 
logger.
    
    This causes a format error in the ndk-build; turn these into warnings with 
-Wno-error=format-security.
---
 gnuradio-runtime/include/gnuradio/logger.h.in | 169 ++++++++++++++++++++++++++
 gnuradio-runtime/lib/CMakeLists.txt           |   8 ++
 2 files changed, 177 insertions(+)

diff --git a/gnuradio-runtime/include/gnuradio/logger.h.in 
b/gnuradio-runtime/include/gnuradio/logger.h.in
index 08cb209..f1d11bb 100644
--- a/gnuradio-runtime/include/gnuradio/logger.h.in
+++ b/gnuradio-runtime/include/gnuradio/logger.h.in
@@ -649,6 +649,173 @@ namespace gr {
   typedef void* logger_ptr;
 } /* namespace gr */
 
+#ifdef ANDROID
+
+#include <android/log.h>
+
+#define LOG_LEVEL ANDROID_LOG_DEBUG
+
+#define GR_LOG_DECLARE_LOGPTR(logger)
+#define GR_LOG_ASSIGN_LOGPTR(logger,name)
+#define GR_CONFIG_LOGGER(config)
+#define GR_CONFIG_AND_WATCH_LOGGER(config,period)
+#define GR_LOG_GETLOGGER(logger, name)
+#define GR_SET_LEVEL(name, level)
+#define GR_LOG_SET_LEVEL(logger, level)
+#define GR_GET_LEVEL(name, level)
+#define GR_LOG_GET_LEVEL(logger, level)
+#define GR_ADD_APPENDER(name,appender)
+#define GR_LOG_ADD_APPENDER(logger,appender)
+#define GR_SET_APPENDER(name,appender)
+#define GR_LOG_SET_APPENDER(logger,appender)
+#define GR_ADD_CONSOLE_APPENDER(logger,target,pattern)
+#define GR_LOG_ADD_CONSOLE_APPENDER(logger,target,pattern)
+#define GR_SET_CONSOLE_APPENDER(logger,target,pattern)
+#define GR_LOG_SET_CONSOLE_APPENDER(logger,target,pattern)
+#define GR_ADD_FILE_APPENDER(name,filename,append,pattern)
+#define GR_LOG_ADD_FILE_APPENDER(logger,filename,append,pattern)
+#define GR_SET_FILE_APPENDER(name,filename,append,pattern)
+#define GR_LOG_SET_FILE_APPENDER(logger,filename,append,pattern)
+#define 
GR_ADD_ROLLINGFILE_APPENDER(name,filename,filesize,bkup_index,append,mode,pattern)
+#define 
GR_LOG_ADD_ROLLINGFILE_APPENDER(logger,filename,filesize,bkup_index,append,mode,pattern)
+#define GR_GET_LOGGER_NAMES(names)
+#define GR_RESET_CONFIGURATION()
+
+#define GR_DEBUG(name, msg) {                                           \
+    if(LOG_LEVEL <= ANDROID_LOG_DEBUG) {                                \
+      std::stringstream s;                                              \
+      s << msg;                                                         \
+      __android_log_print(ANDROID_LOG_DEBUG, name, s.str().c_str());    \
+    }}
+
+#define GR_INFO(name, msg)  {                                           \
+    if(LOG_LEVEL <= ANDROID_LOG_INFO) {                                 \
+      std::stringstream s;                                              \
+      s << msg;                                                         \
+      __android_log_print(ANDROID_LOG_INFO, name, s.str().c_str());     \
+    }}
+
+#define GR_NOTICE(name, msg) {                                          \
+    if(LOG_LEVEL <= ANDROID_LOG_VERBOSE) {                              \
+      std::stringstream s;                                              \
+      s << msg;                                                         \
+      __android_log_print(ANDROID_LOG_VERBOSE, name, s.str().c_str()); \
+    }}
+
+#define GR_WARN(name, msg)  {                                           \
+    if(LOG_LEVEL <= ANDROID_LOG_WARN) {                                 \
+      std::stringstream s;                                              \
+      s << msg;                                                         \
+      __android_log_print(ANDROID_LOG_WARN, name, s.str().c_str());     \
+    }}
+
+#define GR_ERROR(name, msg) {                                           \
+    if(LOG_LEVEL <= ANDROID_LOG_ERROR) {                                \
+      std::stringstream s;                                              \
+      s << msg;                                                         \
+      __android_log_print(ANDROID_LOG_ERROR, name, s.str().c_str());    \
+    }}
+
+#define GR_ALERT(name, msg) {                                           \
+    if(LOG_LEVEL <= ANDROID_LOG_ERROR) {                                \
+      std::stringstream s;                                              \
+      s << msg;                                                         \
+      __android_log_print(ANDROID_LOG_ERROR, name, s.str().c_str());    \
+    }}
+
+#define GR_CRIT(name, msg)  {                                           \
+    if(LOG_LEVEL <= ANDROID_LOG_ERROR) {                                \
+      std::stringstream s;                                              \
+      s << msg;                                                         \
+      __android_log_print(ANDROID_LOG_ERROR, name, s.str().c_str());    \
+    }}
+
+#define GR_FATAL(name, msg) {                                           \
+    if(LOG_LEVEL <= ANDROID_LOG_FATAL) {                                \
+      std::stringstream s;                                              \
+      s << msg;                                                         \
+      __android_log_print(ANDROID_LOG_FATAL, name, s.str().c_str());    \
+    }}
+
+#define GR_EMERG(name, msg) {                                           \
+    if(LOG_LEVEL <= ANDROID_LOG_FATAL) {                                \
+      std::stringstream s;                                              \
+      s << msg;                                                         \
+      __android_log_print(ANDROID_LOG_FATAL, name, s.str().c_str());    \
+    }}
+
+#define GR_ERRORIF(name, cond, msg)
+#define GR_ASSERT(name, cond, msg)
+
+#define GR_LOG_DEBUG(logger, msg) {                                     \
+    if(LOG_LEVEL <= ANDROID_LOG_DEBUG) {                                \
+      std::stringstream s;                                              \
+      s << msg;                                                         \
+      __android_log_print(ANDROID_LOG_DEBUG, "logger", s.str().c_str()); \
+    }}
+
+#define GR_LOG_INFO(logger, msg) {                                      \
+    if(LOG_LEVEL <= ANDROID_LOG_INFO) {                                 \
+      std::stringstream s;                                              \
+      s << msg;                                                         \
+      __android_log_print(ANDROID_LOG_INFO, "logger", s.str().c_str()); \
+    }}
+
+#define GR_LOG_NOTICE(logger, msg) {                                    \
+    if(LOG_LEVEL <= ANDROID_LOG_VERBOSE) {                              \
+      std::stringstream s;                                              \
+      s << msg;                                                         \
+      __android_log_print(ANDROID_LOG_VERBOSE, "logger", s.str().c_str()); \
+    }}
+
+#define GR_LOG_WARN(logger, msg) {                                     \
+    if(LOG_LEVEL <= ANDROID_LOG_WARN) {                                 \
+      std::stringstream s;                                              \
+      s << msg;                                                         \
+      __android_log_print(ANDROID_LOG_WARN, "logger", s.str().c_str()); \
+    }}
+
+#define GR_LOG_ERROR(logger, msg) {                                     \
+    if(LOG_LEVEL <= ANDROID_LOG_ERROR) {                                \
+      std::stringstream s;                                              \
+      s << msg;                                                         \
+      __android_log_print(ANDROID_LOG_ERROR, "logger", s.str().c_str()); \
+    }}
+
+#define GR_LOG_ALERT(logger, msg) {                                     \
+    if(LOG_LEVEL <= ANDROID_LOG_ERROR) {                                \
+      std::stringstream s;                                              \
+      s << msg;                                                         \
+      __android_log_print(ANDROID_LOG_ERROR, "logger", s.str().c_str()); \
+    }}
+
+#define GR_LOG_CRIT(logger, msg) {                                      \
+    if(LOG_LEVEL <= ANDROID_LOG_ERROR) {                                \
+      std::stringstream s;                                              \
+      s << msg;                                                         \
+      __android_log_print(ANDROID_LOG_ERROR, "logger", s.str().c_str()); \
+    }}
+
+#define GR_LOG_FATAL(logger, msg) {                                     \
+    if(LOG_LEVEL <= ANDROID_LOG_FATAL) {                                \
+      std::stringstream s;                                              \
+      s << msg;                                                         \
+      __android_log_print(ANDROID_LOG_FATAL, "logger", s.str().c_str()); \
+    }}
+
+#define GR_LOG_EMERG(logger, msg) {                                     \
+    if(LOG_LEVEL <= ANDROID_LOG_FATAL) {                                \
+      std::stringstream s;                                              \
+      s << msg;                                                         \
+      __android_log_print(ANDROID_LOG_FATAL, "logger", s.str().c_str()); \
+    }}
+
+#define GR_LOG_ERRORIF(logger, cond, msg)
+#define GR_LOG_ASSERT(logger, cond, msg)
+
+
+#else /* ANDROID */
+
 #define GR_LOG_DECLARE_LOGPTR(logger)
 #define GR_LOG_ASSIGN_LOGPTR(logger,name)
 #define GR_CONFIG_LOGGER(config)
@@ -697,6 +864,8 @@ namespace gr {
 #define GR_LOG_ERRORIF(logger, cond, msg)
 #define GR_LOG_ASSERT(logger, cond, msg)
 
+#endif /* ANDROID */
+
 #endif /* ENABLE_GR_LOG */
 
 namespace gr {
diff --git a/gnuradio-runtime/lib/CMakeLists.txt 
b/gnuradio-runtime/lib/CMakeLists.txt
index 5ee90c5..f1add80 100644
--- a/gnuradio-runtime/lib/CMakeLists.txt
+++ b/gnuradio-runtime/lib/CMakeLists.txt
@@ -144,6 +144,14 @@ list(APPEND gnuradio_runtime_libs
     ${LOG4CPP_LIBRARIES}
 )
 
+
+if(ANDROID)
+  list(APPEND gnuradio_runtime_libs
+    log
+  )
+endif(ANDROID)
+
+
 #Add libraries for winsock2.h on Windows
 INCLUDE(CheckIncludeFileCXX)
 CHECK_INCLUDE_FILE_CXX(windows.h HAVE_WINDOWS_H)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]