Add android platform logs
authorKartik Anand <kartik.anand@samsung.com>
Mon, 5 Sep 2022 09:02:28 +0000 (14:32 +0530)
committerYoungjae Shin <yj99.shin@samsung.com>
Tue, 20 Sep 2022 07:44:29 +0000 (16:44 +0900)
CMakeLists.txt
android/aitt/build.gradle
common/aitt_platform.h
common/android/aitt_platform.h [new file with mode: 0644]

index bbde429..2b4146b 100644 (file)
@@ -15,10 +15,11 @@ INCLUDE(FindPkgConfig)
 IF(PLATFORM STREQUAL "android")
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fdiagnostics-color")
        ADD_DEFINITIONS(-DANDROID)
+       ADD_DEFINITIONS(-DPLATFORM=${PLATFORM})
        INCLUDE(${PROJECT_ROOT_DIR}/cmake/aitt_android_flatbuffers.cmake)
        INCLUDE(${PROJECT_ROOT_DIR}/cmake/aitt_android_glib.cmake)
        INCLUDE(${PROJECT_ROOT_DIR}/cmake/aitt_android_mosquitto.cmake)
-       SET(AITT_NEEDS_LIBRARIES ${GLIB_LIBRARIES} ${MOSQUITTO_LIBRARY} ${FLATBUFFERS_LIBRARY})
+       SET(AITT_NEEDS_LIBRARIES ${GLIB_LIBRARIES} ${MOSQUITTO_LIBRARY} ${FLATBUFFERS_LIBRARY} ${LOG_LIBRARIES})
 ELSE(PLATFORM STREQUAL "android")
        IF(PLATFORM STREQUAL "tizen")
                ADD_DEFINITIONS(-DTIZEN)
index 1429134..dfa7d7d 100644 (file)
@@ -20,7 +20,7 @@ android {
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
         externalNativeBuild {
             cmake {
-                arguments '-DLOG_STDOUT=ON'
+                arguments '-DLOG_STDOUT=OFF'
                 arguments '-DCMAKE_VERBOSE_MAKEFILE=1'
                 arguments '-DCMAKE_INSTALL_PREFIX:PATH=/usr'
                 arguments '-DANDROID_STL=c++_shared'
index 3056693..66d2d13 100644 (file)
 
 #if defined(PLATFORM) && !defined(LOG_STDOUT)
 
-#define PURE(x) x
+#define HEADER PLATFORM/aitt_platform.h
 #define TO_STR(x) #x
 #define DEFINE_TO_STR(x) TO_STR(x)
-#include DEFINE_TO_STR(PLATFORM PURE(/) PURE(aitt_platform.h))
+#include DEFINE_TO_STR(HEADER)
 #undef TO_STR
 #undef DEFINE_TO_STR
 
diff --git a/common/android/aitt_platform.h b/common/android/aitt_platform.h
new file mode 100644 (file)
index 0000000..52827b6
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2021-2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <android/log.h>
+
+#define PLATFORM_LOGD(fmt, ...)                     \
+    __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, \
+                        "[%s:%s:%d] " fmt, basename((char *)(__FILE__)), __func__, __LINE__, ##__VA_ARGS__)
+
+#define PLATFORM_LOGI(fmt, ...)                    \
+    __android_log_print(ANDROID_LOG_INFO, LOG_TAG, \
+                        "[%s:%s:%d] " fmt, basename((char *)(__FILE__)), __func__, __LINE__, ##__VA_ARGS__)
+
+#define PLATFORM_LOGE(fmt, ...)                     \
+    __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, \
+                        "[%s:%s:%d] " fmt, basename((char *)(__FILE__)), __func__, __LINE__, ##__VA_ARGS__)