From: Igor Kotrasinski Date: Mon, 30 Apr 2018 09:42:17 +0000 (+0200) Subject: Unconditionally compile main log function X-Git-Tag: submit/tizen/20180828.110226~29 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eac23d2bc0d8071e737db422683d3f2edf44fd81;p=platform%2Fcore%2Fsecurity%2Ftef-simulator.git Unconditionally compile main log function The log function will be used by TAs as well, so we want to conditionally compile only the part for simulator logging. Add a proxy method to logging that evaluates depending on _LOGGING macro and always compile the logging function underneath. Change-Id: I468c932b697fc2a4064928ca2518992c9ab4e298 Signed-off-by: Igor Kotrasinski --- diff --git a/log/log.c b/log/log.c index 4b1e3d6..90948cb 100644 --- a/log/log.c +++ b/log/log.c @@ -154,23 +154,18 @@ const char *GetModuleLevel(IN int32_t module_level) * @return void */ -#ifdef _LOGGING - -__attribute__((visibility("default"))) -void PrintLog(IN const char *function_name, IN const int32_t line_no, - IN int32_t module_level, IN int32_t debug_level, IN const char *message, - ...) +static void PrintLog(IN const char *function_name, IN const int32_t line_no, + IN int32_t module_level, IN int32_t debug_level, + IN const char *message, va_list variable_list) { #ifndef _ANDROID_NDK if (0 == (module_level & gmodule_level) - || 0 == (debug_level & gdebug_level)) + || 0 == (debug_level & gdebug_level)) return; #endif const char *module = GetModuleLevel(module_level); - va_list variable_list; - va_start(variable_list, message); #if defined(__TIZEN__) char buf[512] = {0,}; vsnprintf(buf, 511, message, variable_list); @@ -239,18 +234,18 @@ void PrintLog(IN const char *function_name, IN const int32_t line_no, vprintf(message, variable_list); printf("\n"); #endif - va_end(variable_list); - return; } -#else // ifdef _LOGGING - __attribute__((visibility("default"))) -void PrintLog(IN const char *function_name, IN const int32_t line_no, - IN int32_t module_level, IN int32_t debug_level, IN const char *message, - ...) +void PrintSimulatorLog(IN const char *function_name, IN const int32_t line_no, + IN int32_t module_level, IN int32_t debug_level, + IN const char *message, ...) { - // stub function +#ifdef _LOGGING + va_list args; + va_start(args, message); + PrintLog(function_name, line_no, module_level, debug_level, message, + args); + va_end(args); +#endif } - -#endif // ifdef _LOGGING diff --git a/log/log.h b/log/log.h index 2658c0c..bc3b625 100644 --- a/log/log.h +++ b/log/log.h @@ -102,14 +102,14 @@ typedef enum { #endif #endif // __TIZEN__ -#define _LOG(module_level, debug_level, ...) PrintLog(__FUNCTION__, __LINE__, module_level, debug_level, ##__VA_ARGS__) +#define _LOG(module_level, debug_level, ...) PrintSimulatorLog(__FUNCTION__, __LINE__, module_level, debug_level, ##__VA_ARGS__) -#define LOGE(module_level, ...) PrintLog(__FUNCTION__, __LINE__, module_level, ERROR_LEVEL_LOG, ##__VA_ARGS__) -#define LOGV(module_level, ...) PrintLog(__FUNCTION__, __LINE__, module_level, VERBOSE_LEVEL_LOG, ##__VA_ARGS__) -#define LOGD(module_level, ...) PrintLog(__FUNCTION__, __LINE__, module_level, DEBUG_LEVEL_LOG, ##__VA_ARGS__) -#define LOGI(module_level, ...) PrintLog(__FUNCTION__, __LINE__, module_level, SECURED_LEVEL_LOG, ##__VA_ARGS__) -#define LOGS(module_level, ...) PrintLog(__FUNCTION__, __LINE__, module_level, INFO_LEVEL_LOG, ##__VA_ARGS__) -#define LOGP(module_level, ...) PrintLog(__FUNCTION__, __LINE__, module_level, PACKET_LEVEL_LOG, ##__VA_ARGS__) +#define LOGE(module_level, ...) PrintSimulatorLog(__FUNCTION__, __LINE__, module_level, ERROR_LEVEL_LOG, ##__VA_ARGS__) +#define LOGV(module_level, ...) PrintSimulatorLog(__FUNCTION__, __LINE__, module_level, VERBOSE_LEVEL_LOG, ##__VA_ARGS__) +#define LOGD(module_level, ...) PrintSimulatorLog(__FUNCTION__, __LINE__, module_level, DEBUG_LEVEL_LOG, ##__VA_ARGS__) +#define LOGI(module_level, ...) PrintSimulatorLog(__FUNCTION__, __LINE__, module_level, SECURED_LEVEL_LOG, ##__VA_ARGS__) +#define LOGS(module_level, ...) PrintSimulatorLog(__FUNCTION__, __LINE__, module_level, INFO_LEVEL_LOG, ##__VA_ARGS__) +#define LOGP(module_level, ...) PrintSimulatorLog(__FUNCTION__, __LINE__, module_level, PACKET_LEVEL_LOG, ##__VA_ARGS__) #if defined(__cplusplus) extern "C" { @@ -150,7 +150,7 @@ void SetDebugAndModuleLevel(IN const int32_t module_level, IN const int32_t debug_level); /* - * This method is used to print the debug logs + * This method is used to print the simulator debug logs * * @param function_name * [IN] name of the fuction @@ -169,10 +169,9 @@ void SetDebugAndModuleLevel(IN const int32_t module_level, * * @return void */ -void PrintLog(IN const char* function_name, IN const int32_t line_no, - IN int32_t module_level, IN int32_t debug_level, IN const char* message, - ...); - +void PrintSimulatorLog(IN const char* function_name, IN const int32_t line_no, + IN int32_t module_level, IN int32_t debug_level, + IN const char* message, ...); #if defined(__cplusplus) } // extern "C" #endif