Add internal header to define common log formats.
Signed-off-by: Jaeyun <jy1210.jung@samsung.com>
#define __NNSTREAMER_ANDROID_NATIVE_H__
#include <jni.h>
-#include <android/log.h>
#include <gst/gst.h>
#include "nnstreamer.h"
#include "nnstreamer-single.h"
#include "nnstreamer-capi-private.h"
+#include "nnstreamer_log.h"
#include "nnstreamer_plugin_api.h"
#include "nnstreamer_plugin_api_filter.h"
-#define TAG "NNStreamer-native"
-
-#define nns_logi(...) \
- __android_log_print (ANDROID_LOG_INFO, TAG, __VA_ARGS__)
-
-#define nns_logw(...) \
- __android_log_print (ANDROID_LOG_WARN, TAG, __VA_ARGS__)
-
-#define nns_loge(...) \
- __android_log_print (ANDROID_LOG_ERROR, TAG, __VA_ARGS__)
-
-#define nns_logd(...) \
- __android_log_print (ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)
-
#if GLIB_SIZEOF_VOID_P == 8
#define CAST_TO_LONG(p) (jlong)(p)
#define CAST_TO_TYPE(l,type) (type)(l)
#include "nnstreamer.h"
#include "nnstreamer-single.h"
#include "tensor_typedef.h"
+#include "nnstreamer_log.h"
/* Tizen ML feature */
#if defined (__TIZEN__)
#define release_tizen_resource(...)
#endif
-#define TAG_NAME "nnstreamer-capi"
-
-#if defined(__TIZEN__)
- #include <dlog.h>
-
- #define ml_logi(...) \
- dlog_print (DLOG_INFO, TAG_NAME, __VA_ARGS__)
-
- #define ml_logw(...) \
- dlog_print (DLOG_WARN, TAG_NAME, __VA_ARGS__)
-
- #define ml_loge(...) \
- dlog_print (DLOG_ERROR, TAG_NAME, __VA_ARGS__)
-
- #define ml_logd(...) \
- dlog_print (DLOG_DEBUG, TAG_NAME, __VA_ARGS__)
-
-#elif defined(__ANDROID__)
- #include <android/log.h>
-
- #define ml_logi(...) \
- __android_log_print (ANDROID_LOG_INFO, TAG_NAME, __VA_ARGS__)
-
- #define ml_logw(...) \
- __android_log_print (ANDROID_LOG_WARN, TAG_NAME, __VA_ARGS__)
-
- #define ml_loge(...) \
- __android_log_print (ANDROID_LOG_ERROR, TAG_NAME, __VA_ARGS__)
-
- #define ml_logd(...) \
- __android_log_print (ANDROID_LOG_DEBUG, TAG_NAME, __VA_ARGS__)
-
-#else /* Linux distro */
- #define ml_logi g_info
- #define ml_logw g_warning
- #define ml_loge g_critical
- #define ml_logd g_debug
-#endif
-
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
]
if have_orcc
- nnstreamer_base_deps += [orc_dep]
+ nnstreamer_base_deps += orc_dep
+endif
+
+if build_platform == 'tizen'
+ nnstreamer_base_deps += dependency('dlog')
endif
# Internal dependencies
--- /dev/null
+/**
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ */
+
+/**
+ * @file nnstreamer_log.h
+ * @date 12 Mar 2020
+ * @brief Internal log util for NNStreamer plugins and native APIs.
+ * @see http://github.com/nnsuite/nnstreamer
+ * @author Jaeyun Jung <jy1210.jung@samsung.com>
+ * @bug No known bugs except for NYI items
+ */
+
+#ifndef __NNSTREAMER_LOG_H__
+#define __NNSTREAMER_LOG_H__
+
+G_BEGIN_DECLS
+
+#define TAG_NAME "nnstreamer"
+
+#if defined(__TIZEN__)
+#include <dlog.h>
+
+#define ml_logi(...) \
+ dlog_print (DLOG_INFO, TAG_NAME, __VA_ARGS__)
+
+#define ml_logw(...) \
+ dlog_print (DLOG_WARN, TAG_NAME, __VA_ARGS__)
+
+#define ml_loge(...) \
+ dlog_print (DLOG_ERROR, TAG_NAME, __VA_ARGS__)
+
+#define ml_logd(...) \
+ dlog_print (DLOG_DEBUG, TAG_NAME, __VA_ARGS__)
+
+#elif defined(__ANDROID__)
+#include <android/log.h>
+
+#define ml_logi(...) \
+ __android_log_print (ANDROID_LOG_INFO, TAG_NAME, __VA_ARGS__)
+
+#define ml_logw(...) \
+ __android_log_print (ANDROID_LOG_WARN, TAG_NAME, __VA_ARGS__)
+
+#define ml_loge(...) \
+ __android_log_print (ANDROID_LOG_ERROR, TAG_NAME, __VA_ARGS__)
+
+#define ml_logd(...) \
+ __android_log_print (ANDROID_LOG_DEBUG, TAG_NAME, __VA_ARGS__)
+
+#else /* Linux distro */
+#include <glib.h>
+
+#define ml_logi g_info
+#define ml_logw g_warning
+#define ml_loge g_critical
+#define ml_logd g_debug
+#endif
+
+#define nns_logi ml_logi
+#define nns_logw ml_logw
+#define nns_loge ml_loge
+#define nns_logd ml_logd
+
+G_END_DECLS
+#endif /* __NNSTREAMER_LOG_H__ */
#include <gst/base/gstcollectpads.h>
#include "tensor_typedef.h"
+#include "nnstreamer_log.h"
#include "nnstreamer_plugin_api.h"
#ifdef HAVE_ORC
if (result) {
/* print warning message */
- g_warning ("Tensor info :\n%s", result);
+ nns_logw ("Tensor info :\n%s", result);
g_free (result);
}
}
LOCAL_SRC_FILES += ../tests/nnstreamer_repo_dynamicity/tensor_repo_dynamic_test.c
LOCAL_CFLAGS += -O0 -DVERSION=\"$(NNSTREAMER_VERSION)\"
LOCAL_CXXFLAGS += -std=c++11 -DVERSION=\"$(NNSTREAMER_VERSION)\"
+LOCAL_LDLIBS := -llog
LOCAL_LDFLAGS := $(CUSTOM_LINKER64)
LOCAL_C_INCLUDES := $(NNSTREAMER_INCLUDES)
LOCAL_CXXFLAGS += -DNO_AUDIO
endif
+LOCAL_LDLIBS := -llog
LOCAL_LDFLAGS += -fuse-ld=bfd
LOCAL_MODULE_TAGS := optional
#include <gst/gst.h>
#include <tensor_common.h>
-#define print_log(...) if (!silent) g_message (__VA_ARGS__)
+#define _print_log(...) if (!silent) g_message (__VA_ARGS__)
#define make_gst_element(element) do{\
element = gst_element_factory_make(#element, #element);\
if (!element) {\
static gboolean
bus_callback (GstBus * bus, GstMessage * message, gpointer data)
{
- print_log ("Got %s message\n", GST_MESSAGE_TYPE_NAME (message));
+ _print_log ("Got %s message\n", GST_MESSAGE_TYPE_NAME (message));
switch (GST_MESSAGE_TYPE (message)) {
case GST_MESSAGE_ERROR:{
gchar *debug;
gst_message_parse_error (message, &err, &debug);
- print_log ("Error: %s\n", err->message);
+ _print_log ("Error: %s\n", err->message);
g_error_free (err);
g_free (debug);
g_object_set (G_OBJECT (tensor_filter), "model", model_path, NULL);
- print_log ("Model %s is just reloaded\n", model_path);
+ _print_log ("Model %s is just reloaded\n", model_path);
is_first = !is_first;
g_main_loop_quit (loop);
- print_log ("Now stop the loop\n");
+ _print_log ("Now stop the loop\n");
/* stop */
return FALSE;