Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix] Modify dlog output code #191

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions include/nnstreamer-edge.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,6 @@ typedef enum {
NNS_EDGE_NODE_TYPE_UNKNOWN,
} nns_edge_node_type_e;

/**
* @brief Enumeration for log message.
*/
typedef enum {
NNS_EDGE_LOG_DEBUG = 0,
NNS_EDGE_LOG_INFO,
NNS_EDGE_LOG_WARNING,
NNS_EDGE_LOG_ERROR,
NNS_EDGE_LOG_FATAL,
NNS_EDGE_LOG_NONE
} nns_edge_log_level_e;

/**
* @brief Callback for the nnstreamer edge event.
* @note This callback will suspend data stream. Do not spend too much time in the callback.
Expand Down Expand Up @@ -488,12 +476,6 @@ int nns_edge_data_get_info (nns_edge_data_h data_h, const char *key, char **valu
*/
int nns_edge_data_clear_info (nns_edge_data_h data_h);

/**
* @brief Set the logging level. Default value is NNS_EDGE_LOG_INFO.
* @param[in] level The log level to print out.
*/
void nns_edge_set_log_level (nns_edge_log_level_e level);
Comment on lines -492 to -495
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just remove this function? How can we set log level after this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Operation is possible without nns_edge_set_log_level().


/**
* @brief Get the version of nnstreamer-edge.
* @param[out] major MAJOR.minor.micro, won't set if it's null.
Expand Down
1 change: 0 additions & 1 deletion jni/nnstreamer-edge.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ NNSTREAMER_EDGE_SRCS := \
$(NNSTREAMER_EDGE_ROOT)/src/libnnstreamer-edge/nnstreamer-edge-data.c \
$(NNSTREAMER_EDGE_ROOT)/src/libnnstreamer-edge/nnstreamer-edge-event.c \
$(NNSTREAMER_EDGE_ROOT)/src/libnnstreamer-edge/nnstreamer-edge-internal.c \
$(NNSTREAMER_EDGE_ROOT)/src/libnnstreamer-edge/nnstreamer-edge-log.c \
$(NNSTREAMER_EDGE_ROOT)/src/libnnstreamer-edge/nnstreamer-edge-metadata.c \
$(NNSTREAMER_EDGE_ROOT)/src/libnnstreamer-edge/nnstreamer-edge-queue.c \
$(NNSTREAMER_EDGE_ROOT)/src/libnnstreamer-edge/nnstreamer-edge-util.c
Expand Down
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ SET(NNS_EDGE_SRCS
${NNS_EDGE_SRC_DIR}/nnstreamer-edge-data.c
${NNS_EDGE_SRC_DIR}/nnstreamer-edge-event.c
${NNS_EDGE_SRC_DIR}/nnstreamer-edge-internal.c
${NNS_EDGE_SRC_DIR}/nnstreamer-edge-log.c
${NNS_EDGE_SRC_DIR}/nnstreamer-edge-util.c
${NNS_EDGE_SRC_DIR}/nnstreamer-edge-queue.c
)
IF (NOT ENABLE_TIZEN)
SET(NNS_EDGE_SRCS ${NNS_EDGE_SRCS} ${NNS_EDGE_SRC_DIR}/nnstreamer-edge-log.c)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the nnstreamer-edge-log.c excluded when ENABLE_TIZEN is off?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not using Tizen or Android, nns_edge_print_log() in nnstreamer-edge-log.c is used.

ENDIF()

IF(MQTT_SUPPORT)
IF(MOSQUITTO_LIB)
Expand Down
36 changes: 0 additions & 36 deletions src/libnnstreamer-edge/nnstreamer-edge-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,6 @@
#define DEBUG 0
#endif

#if defined(__TIZEN__)
#include <dlog.h>

#define _print_logd(...) dlog_print (DLOG_DEBUG, TAG_NAME, __VA_ARGS__)
#define _print_logi(...) dlog_print (DLOG_INFO, TAG_NAME, __VA_ARGS__)
#define _print_logw(...) dlog_print (DLOG_WARN, TAG_NAME, __VA_ARGS__)
#define _print_loge(...) dlog_print (DLOG_ERROR, TAG_NAME, __VA_ARGS__)
#define _print_logf(...) dlog_print (DLOG_FATAL, TAG_NAME, __VA_ARGS__)
#elif defined(__ANDROID__)
#include <android/log.h>

#define _print_logd(...) __android_log_print (ANDROID_LOG_DEBUG, TAG_NAME, __VA_ARGS__)
#define _print_logi(...) __android_log_print (ANDROID_LOG_INFO, TAG_NAME, __VA_ARGS__)
#define _print_logw(...) __android_log_print (ANDROID_LOG_WARN, TAG_NAME, __VA_ARGS__)
#define _print_loge(...) __android_log_print (ANDROID_LOG_ERROR, TAG_NAME, __VA_ARGS__)
#define _print_logf(...) __android_log_print (ANDROID_LOG_FATAL, TAG_NAME, __VA_ARGS__)
#else
/**
* @brief Internal util function to print log message.
*/
Expand Down Expand Up @@ -75,22 +58,6 @@ _ne_log_print (nns_edge_log_level_e level, const char *fmt, va_list args)
#define _print_logw(...) _ne_log_print (NNS_EDGE_LOG_WARNING, __VA_ARGS__)
#define _print_loge(...) _ne_log_print (NNS_EDGE_LOG_ERROR, __VA_ARGS__)
#define _print_logf(...) _ne_log_print (NNS_EDGE_LOG_FATAL, __VA_ARGS__)
#endif

/**
* @brief Internal logging level.
*/
static nns_edge_log_level_e g_ne_log_level =
(DEBUG) ? NNS_EDGE_LOG_DEBUG : NNS_EDGE_LOG_INFO;

/**
* @brief Set the logging level.
*/
void
nns_edge_set_log_level (nns_edge_log_level_e level)
{
g_ne_log_level = level;
}

/**
* @brief Internal util function to print log message.
Expand All @@ -100,9 +67,6 @@ nns_edge_print_log (nns_edge_log_level_e level, const char *fmt, ...)
{
va_list args;

if (level < g_ne_log_level)
return;

va_start (args, fmt);

switch (level) {
Expand Down
31 changes: 30 additions & 1 deletion src/libnnstreamer-edge/nnstreamer-edge-log.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,35 @@ extern "C" {

#define TAG_NAME "nnstreamer-edge"

#if defined(__TIZEN__)
#include <dlog.h>

#define nns_edge_logd(...) dlog_print (DLOG_DEBUG, TAG_NAME, __VA_ARGS__)
#define nns_edge_logi(...) dlog_print (DLOG_INFO, TAG_NAME, __VA_ARGS__)
#define nns_edge_logw(...) dlog_print (DLOG_WARN, TAG_NAME, __VA_ARGS__)
#define nns_edge_loge(...) dlog_print (DLOG_ERROR, TAG_NAME, __VA_ARGS__)
#define nns_edge_logf(...) dlog_print (DLOG_FATAL, TAG_NAME, __VA_ARGS__)
#elif defined(__ANDROID__)
#include <android/log.h>

#define nns_edge_logd(...) __android_log_print (ANDROID_LOG_DEBUG, TAG_NAME, __VA_ARGS__)
#define nns_edge_logi(...) __android_log_print (ANDROID_LOG_INFO, TAG_NAME, __VA_ARGS__)
#define nns_edge_logw(...) __android_log_print (ANDROID_LOG_WARN, TAG_NAME, __VA_ARGS__)
#define nns_edge_loge(...) __android_log_print (ANDROID_LOG_ERROR, TAG_NAME, __VA_ARGS__)
#define nns_edge_logf(...) __android_log_print (ANDROID_LOG_FATAL, TAG_NAME, __VA_ARGS__)
#else
songgot marked this conversation as resolved.
Show resolved Hide resolved
/**
* @brief Enumeration for log message.
*/
typedef enum {
NNS_EDGE_LOG_DEBUG = 0,
NNS_EDGE_LOG_INFO,
NNS_EDGE_LOG_WARNING,
NNS_EDGE_LOG_ERROR,
NNS_EDGE_LOG_FATAL,
NNS_EDGE_LOG_NONE
} nns_edge_log_level_e;

/**
* @brief Internal util function to print log message.
*/
Expand All @@ -32,7 +61,7 @@ void nns_edge_print_log (nns_edge_log_level_e level, const char *fmt, ...);
#define nns_edge_loge(...) nns_edge_print_log (NNS_EDGE_LOG_ERROR, __VA_ARGS__)
#define nns_edge_logd(...) nns_edge_print_log (NNS_EDGE_LOG_DEBUG, __VA_ARGS__)
#define nns_edge_logf(...) nns_edge_print_log (NNS_EDGE_LOG_FATAL, __VA_ARGS__)

#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
Expand Down
4 changes: 2 additions & 2 deletions src/libnnstreamer-edge/nnstreamer-edge-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define _GNU_SOURCE
#include <stdio.h>
#include <stdarg.h>

#include <inttypes.h>
#include "nnstreamer-edge-log.h"
#include "nnstreamer-edge-util.h"

Expand Down Expand Up @@ -174,7 +174,7 @@ nns_edge_malloc (nns_size_t size)
mem = malloc (size);

if (!mem)
nns_edge_loge ("Failed to allocate memory (%llu).", size);
nns_edge_loge ("Failed to allocate memory (%" PRIu64 ").", size);

return mem;
}
Expand Down
Loading