From: Igor Kotrasinski Date: Tue, 8 May 2018 12:43:16 +0000 (+0200) Subject: Return logged length in TA logger function X-Git-Tag: submit/tizen/20180828.110226~24 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6ee221bdd03369403de40dcb24bce4598ac478ce;p=platform%2Fcore%2Fsecurity%2Ftef-simulator.git Return logged length in TA logger function Change-Id: I93f93761298adc2791d9ac3c3cf6bd41040e8e26 Signed-off-by: Igor Kotrasinski --- diff --git a/log/log.c b/log/log.c index acd3f14..ce3cc81 100644 --- a/log/log.c +++ b/log/log.c @@ -29,6 +29,7 @@ #include #define LOG_FMT "[%s][%s:%d]%s\n" +#define MAX_TAG_LENGTH 256 /*----------------------------------------------------------------------------- * Globals @@ -196,31 +197,36 @@ static android_LogPriority logLevelToAndroidLogLevel(LogLevel log_level) } #endif -void PrintLog(IN const char *tag, IN const char *function_name, - IN const int32_t line_no, IN int32_t module_level, - IN LogLevel log_level, IN const char *message, - va_list variable_list) +int PrintLog(IN const char *tag, IN const char *function_name, + IN const int32_t line_no, IN int32_t module_level, + IN LogLevel log_level, IN const char *message, + va_list variable_list) { if (!(module_level & gmodule_level) || log_level > glog_level) - return; + return 0; + int ret_len = 0; + int ret; const char *module = getModuleLevelString(module_level); char buf[512] = {'\0'}; vsnprintf(buf, sizeof(buf), message, variable_list); #if defined(__TIZEN__) log_priority prio = logLevelToDlogLevel(log_level); - dlog_print(prio, tag, LOG_FMT, - module, function_name, line_no, buf); + ret = dlog_print(prio, tag, LOG_FMT, + module, function_name, line_no, buf); #elif defined(_ANDROID_NDK) android_LogPriority prio = logLevelToAndroidLogLevel(log_level); - __android_log_print(prio, tag, LOG_FMT, - module, function_name, line_no, buf); + ret = __android_log_print(prio, tag, LOG_FMT, + module, function_name, line_no, buf); #else const char *severity = getDebugLevelString(log_level); - printf("[%s] [%s]"LOG_FMT, tag, severity, module, function_name, - line_no, buf); + ret = printf("[%s] [%s]"LOG_FMT, tag, severity, module, function_name, + line_no, buf); #endif + if (ret >= 0) + ret_len += ret; + return ret_len; } __attribute__((visibility("default"))) diff --git a/log/log.h b/log/log.h index 93c4d33..ff93889 100644 --- a/log/log.h +++ b/log/log.h @@ -166,10 +166,10 @@ void PrintSimulatorLog(IN const char* function_name, IN const int32_t line_no, IN int32_t module_level, IN int32_t log_level, IN const char* message, ...); -void PrintLog(IN const char *tag, IN const char *function_name, - IN const int32_t line_no, IN int32_t module_level, - IN LogLevel log_level, IN const char *message, - va_list variable_list); +int PrintLog(IN const char *tag, IN const char *function_name, + IN const int32_t line_no, IN int32_t module_level, + IN LogLevel log_level, IN const char *message, + va_list variable_list); #if defined(__cplusplus) } // extern "C" #endif diff --git a/log/ta_log.c b/log/ta_log.c index 291c3e2..dfb34c7 100644 --- a/log/ta_log.c +++ b/log/ta_log.c @@ -107,6 +107,7 @@ int __logger_log(const char* tag, const usr_log_level lv, const int line, ...) { LogLevel ta_log_level = taLogLevelToLogLevel(lv); + int ret; if (fmt == NULL || function == NULL) return 0; @@ -117,9 +118,10 @@ int __logger_log(const char* tag, const usr_log_level lv, va_list args; va_start(args, line); - PrintLog(log_label, function, line, MODULE_CLIENT_TA, ta_log_level, fmt, args); + ret = PrintLog(log_label, function, line, MODULE_CLIENT_TA, + ta_log_level, fmt, args); va_end(args); - return 0; // TODO + return ret; } void initDebugLogLevel(const char* fmt, ...)