/* * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Contact: Jeonghoon Park * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/license/ * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __CAR_APP_LOG_H__ #define __CAR_APP_LOG_H__ #include #include #include #include #ifdef LOG_TAG #undef LOG_TAG #endif #define LOG_TAG "GEAR-RACING-CONTROLLER" #define _D(fmt, arg...) dlog_print(DLOG_DEBUG, LOG_TAG, "[%s:%s():%d] "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##arg) #define _I(fmt, arg...) dlog_print(DLOG_INFO, LOG_TAG, "[%s:%s():%d] "fmt , basename(__FILE__), __FUNCTION__, __LINE__, ##arg) #define _W(fmt, arg...) dlog_print(DLOG_WARN, LOG_TAG, "[%s:%s():%d] "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##arg) #define _E(fmt, arg...) dlog_print(DLOG_ERROR, LOG_TAG, "[%s:%s():%d] "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##arg) #define _F(fmt, arg...) dlog_print(DLOG_FATAL, LOG_TAG, "\033[1;41m[%s:%s():%d] "fmt"\033[0m", basename(__FILE__), __FUNCTION__, __LINE__, ##arg) #define FUNCTION_START dlog_print(DLOG_DEBUG, LOG_TAG, "[%s:%s():%d]\033[0;35m %s() [START]\033[0m", basename(__FILE__), __FUNCTION__, __LINE__, __FUNCTION__) #define FUNCTION_END dlog_print(DLOG_DEBUG, LOG_TAG, "[%s:%s():%d]\033[0;35m %s() [END]\033[0m", basename(__FILE__), __FUNCTION__, __LINE__, __FUNCTION__) #define ASSERT(condition, fmt, arg...) \ if (condition) { \ _F(fmt, ##arg); \ assert(condition); \ } \ #define ASSERT_MEMORY(condition) ASSERT(condition, "Failed to create: %s", #condition) #define ASSERT_FUNCTION(condition) ASSERT(condition, "Function error: %s", #condition) #define ASSERT_FUNCTION_RET(condition, ret) ASSERT(condition, "Function error: %s. Error: %s", get_error_name(ret)) #define PLAYER_NAME_MAX_LEN 255 //Limited by PLAYERN_NAME_MAX_LEN in model //#define FRAME_DEBUG #ifdef FRAME_DEBUG #define _FRAME_D(fmt, arg...) _D(fmt, arg) #define _FRAME_I(fmt, arg...) _I(fmt, arg) #define _FRAME_W(fmt, arg...) _W(fmt, arg) #define _FRAME_E(fmt, arg...) _E(fmt, arg) #define _FRAME_F(fmt, arg...) _F(fmt, arg) #else #define _FRAME_D(fmt, arg...) do { } while(0) #define _FRAME_I(fmt, arg...) do { } while(0) #define _FRAME_W(fmt, arg...) do { } while(0) #define _FRAME_E(fmt, arg...) do { } while(0) #define _FRAME_F(fmt, arg...) do { } while(0) #endif #define retvm_if(expr, val, fmt, arg...) do { \ if (expr) { \ _E(fmt, ##arg); \ _E("(%s) -> %s() return", #expr, __FUNCTION__); \ return val; \ } \ } while (0) #define retv_if(expr, val) do { \ if (expr) { \ _E("(%s) -> %s() return", #expr, __FUNCTION__); \ return (val); \ } \ } while (0) #define retm_if(expr, fmt, arg...) do { \ if (expr) { \ _E(fmt, ##arg); \ _E("(%s) -> %s() return", #expr, __FUNCTION__); \ return; \ } \ } while (0) #define ret_if(expr) do { \ if (expr) { \ _E("(%s) -> %s() return", #expr, __FUNCTION__); \ return; \ } \ } while (0) #define goto_if(expr, val) do { \ if (expr) { \ _E("(%s) -> goto", #expr); \ goto val; \ } \ } while (0) #define break_if(expr) { \ if (expr) { \ _E("(%s) -> break", #expr); \ break; \ } \ } #define continue_if(expr) { \ if (expr) { \ _E("(%s) -> continue", #expr); \ continue; \ } \ } typedef enum { LOG_TYPE_DLOG = 0, LOG_TYPE_FILE, LOG_TYPE_ALL, } log_type; int log_print(log_priority prio, const char *tag, const char *fmt, ...); int log_type_set(log_type type); void log_file_close(void); #endif /* __CAR_APP_LOG_H__ */