Enable resource/connnectivity logging for osx/ios
authorSakari Poussa <sakari.poussa@intel.com>
Tue, 18 Aug 2015 10:46:37 +0000 (13:46 +0300)
committerJon A. Cruz <jonc@osg.samsung.com>
Thu, 20 Aug 2015 19:38:53 +0000 (19:38 +0000)
Change-Id: I31d065cf3d35fe5b94fbdd9a6d10b65c07a1fc2d
Signed-off-by: Sakari Poussa <sakari.poussa@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2229
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Charlie Lenahan <charlie.lenahan@intel.com>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
build_common/darwin/SConscript
resource/csdk/connectivity/common/src/logger.c

index 4cbb981..73bb047 100644 (file)
@@ -58,6 +58,9 @@ else:
        env.AppendUnique(CCFLAGS = ['-g'])
        env.AppendUnique(LINKFLAGS = ['-g'])
 
+if env.get('LOGGING'):
+    env.AppendUnique(CPPDEFINES = ['-DTB_LOG'])
+
 if target_os == 'darwin':
        sys_root = tc_path + '/Platforms/MacOSX.platform/Developer/SDKs/MacOSX' + sys_version + '.sdk/'
 else:
index 2a751ff..bcdc905 100644 (file)
@@ -74,7 +74,7 @@ static const char *LEVEL[] =
 static android_LogPriority LEVEL[] =
 {   ANDROID_LOG_DEBUG, ANDROID_LOG_INFO, ANDROID_LOG_WARN, ANDROID_LOG_ERROR, ANDROID_LOG_FATAL};
 #endif
-#elif defined __linux__
+#elif defined (__linux__) || defined (__APPLE__)
 static const char *LEVEL[] __attribute__ ((unused)) =
 {   "DEBUG", "INFO", "WARNING", "ERROR", "FATAL"};
 #elif defined ARDUINO
@@ -116,7 +116,7 @@ void OICLogInit()
 
 void OICLogShutdown()
 {
-#ifdef __linux__
+#if defined(__linux__) || defined(__APPLE__)
     if (logCtx && logCtx->destroy)
     {
         logCtx->destroy(logCtx);
@@ -147,7 +147,7 @@ void OICLog(LogLevel level, const char *tag, const char *logStr)
     __android_log_write(LEVEL[level], tag, logStr);
 #endif
 
-#elif defined __linux__
+#elif defined __linux__ || defined __APPLE__
     if (logCtx && logCtx->write_level)
     {
         logCtx->write_level(logCtx, LEVEL_XTABLE[level], logStr);
@@ -158,7 +158,7 @@ void OICLog(LogLevel level, const char *tag, const char *logStr)
         int min = 0;
         int sec = 0;
         int ms = 0;
-#ifdef _POSIX_TIMERS
+#if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0
         struct timespec when = { 0, 0 };
         clockid_t clk = CLOCK_REALTIME;
 #ifdef CLOCK_REALTIME_COARSE