Skip to content

Commit

Permalink
[bugfix] Modify dlog output code
Browse files Browse the repository at this point in the history
When outputting dlog using dlogutil in Tizen, garbage values are output
in the format starting with %

Signed-off-by: hyunil park <[email protected]>
  • Loading branch information
songgot committed Dec 6, 2023
1 parent ded7b09 commit 118bf4c
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 59 deletions.
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);

/**
* @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)
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
/**
* @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
3 changes: 1 addition & 2 deletions src/libnnstreamer-edge/nnstreamer-edge-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#define _GNU_SOURCE
#include <stdio.h>
#include <stdarg.h>

#include "nnstreamer-edge-log.h"
#include "nnstreamer-edge-util.h"

Expand Down Expand Up @@ -174,7 +173,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");

return mem;
}
Expand Down

0 comments on commit 118bf4c

Please sign in to comment.