4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Ja-young Gu <jygu@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
21 #ifndef __TCORE_LOG_H__
22 #define __TCORE_LOG_H__
27 extern gboolean tcore_debug;
29 #ifdef FEATURE_DLOG_DEBUG
34 #define TCORE_LOG_TAG "UNKNOWN"
37 #define info(fmt,args...) { if(tcore_debug) RLOG(LOG_INFO, TCORE_LOG_TAG, fmt "\n", ##args); }
38 #define msg(fmt,args...) { if(tcore_debug) RLOG(LOG_DEBUG, TCORE_LOG_TAG, fmt "\n", ##args); }
39 #define dbg(fmt,args...) { if(tcore_debug) RLOG(LOG_DEBUG, TCORE_LOG_TAG, fmt "\n", ##args); }
40 #define warn(fmt,args...) { RLOG(LOG_WARN, TCORE_LOG_TAG, fmt "\n", ##args); }
41 #define err(fmt,args...) { RLOG(LOG_ERROR, TCORE_LOG_TAG, fmt "\n", ##args); }
42 #define fatal(fmt,args...) { RLOG(LOG_FATAL, TCORE_LOG_TAG, fmt "\n", ##args); }
44 #elif defined(FEATURE_TLOG_DEBUG)
47 #define TCORE_LOG_TAG "UNKNOWN"
51 TCORE_LOG_TYPE_MAIN = 0,
53 TCORE_LOG_TYPE_SYSTEM,
54 TCORE_LOG_TYPE_TIME_CHECK
57 enum tcore_log_priority {
58 TCORE_LOG_UNKNOWN = 0,
70 * Virtual log function.
71 * Daemon should implement the actual content. (printrf/file writing/...)
73 void tcore_log(enum tcore_log_type type, enum tcore_log_priority priority, const char *tag, const char *fmt, ...);
75 #define info(fmt,args...) { if(tcore_debug) tcore_log(TCORE_LOG_TYPE_RADIO, TCORE_LOG_INFO, TCORE_LOG_TAG, fmt "\n", ##args); }
76 #define msg(fmt,args...) { if(tcore_debug) tcore_log(TCORE_LOG_TYPE_RADIO, TCORE_LOG_DEBUG, TCORE_LOG_TAG, fmt "\n", ##args); }
77 #define dbg(fmt,args...) { if(tcore_debug) tcore_log(TCORE_LOG_TYPE_RADIO, TCORE_LOG_DEBUG, TCORE_LOG_TAG, "<%s:%d> " fmt "\n", __func__, __LINE__, ##args); }
78 #define warn(fmt,args...) { tcore_log(TCORE_LOG_TYPE_RADIO, TCORE_LOG_WARN, TCORE_LOG_TAG, "<%s:%d> " fmt "\n", __func__, __LINE__, ##args); }
79 #define err(fmt,args...) { tcore_log(TCORE_LOG_TYPE_RADIO, TCORE_LOG_ERROR, TCORE_LOG_TAG, "<%s:%d> " fmt "\n", __func__, __LINE__, ##args); }
80 #define fatal(fmt,args...) { tcore_log(TCORE_LOG_TYPE_RADIO, TCORE_LOG_FATAL, TCORE_LOG_TAG, "<%s:%d> " fmt "\n", __func__, __LINE__, ##args); }
82 #define info_ex(tag,fmt,args...) { if(tcore_debug) tcore_log(TCORE_LOG_TYPE_RADIO, TCORE_LOG_INFO, tag, fmt "\n", ##args); }
83 #define msg_ex(tag,fmt,args...) { if(tcore_debug) tcore_log(TCORE_LOG_TYPE_RADIO, TCORE_LOG_DEBUG, tag, fmt "\n", ##args); }
84 #define dbg_ex(tag,fmt,args...) { if(tcore_debug) tcore_log(TCORE_LOG_TYPE_RADIO, TCORE_LOG_DEBUG, tag, "<%s:%d> " fmt "\n", __func__, __LINE__, ##args); }
85 #define warn_ex(tag,fmt,args...) { tcore_log(TCORE_LOG_TYPE_RADIO, TCORE_LOG_WARN, tag, "<%s:%d> " fmt "\n", __func__, __LINE__, ##args); }
86 #define err_ex(tag,fmt,args...) { tcore_log(TCORE_LOG_TYPE_RADIO, TCORE_LOG_ERROR, tag, "<%s:%d> " fmt "\n", __func__, __LINE__, ##args); }
87 #define fatal_ex(tag,fmt,args...) { tcore_log(TCORE_LOG_TYPE_RADIO, TCORE_LOG_FATAL, tag, "<%s:%d> " fmt "\n", __func__, __LINE__, ##args); }
89 #define TIME_CHECK(fmt,args...) { tcore_log(TCORE_LOG_TYPE_TIME_CHECK, TCORE_LOG_INFO, "TIME_CHECK", fmt "\n", ##args); }
93 #define ANSI_COLOR_NORMAL "\e[0m"
95 #define ANSI_COLOR_BLACK "\e[0;30m"
96 #define ANSI_COLOR_RED "\e[0;31m"
97 #define ANSI_COLOR_GREEN "\e[0;32m"
98 #define ANSI_COLOR_BROWN "\e[0;33m"
99 #define ANSI_COLOR_BLUE "\e[0;34m"
100 #define ANSI_COLOR_MAGENTA "\e[0;35m"
101 #define ANSI_COLOR_CYAN "\e[0;36m"
102 #define ANSI_COLOR_LIGHTGRAY "\e[0;37m"
104 #define ANSI_COLOR_DARKGRAY "\e[1;30m"
105 #define ANSI_COLOR_LIGHTRED "\e[1;31m"
106 #define ANSI_COLOR_LIGHTGREEN "\e[1;32m"
107 #define ANSI_COLOR_YELLOW "\e[1;33m"
108 #define ANSI_COLOR_LIGHTBLUE "\e[1;34m"
109 #define ANSI_COLOR_LIGHTMAGENTA "\e[1;35m"
110 #define ANSI_COLOR_LIGHTCYAN "\e[1;36m"
111 #define ANSI_COLOR_WHITE "\e[1;37m"
113 #ifndef TCORE_LOG_FILE
114 #define TCORE_LOG_FILE stdout
117 #ifndef TCORE_LOG_FUNC
118 #define TCORE_LOG_FUNC fprintf
121 #define info(fmt,args...) { if(tcore_debug) TCORE_LOG_FUNC(TCORE_LOG_FILE, fmt "\n", ##args); fflush(TCORE_LOG_FILE);}
122 #define msg(fmt,args...) { if(tcore_debug) TCORE_LOG_FUNC(TCORE_LOG_FILE, fmt "\n", ##args); fflush(TCORE_LOG_FILE);}
123 #define dbg(fmt,args...) { if(tcore_debug) TCORE_LOG_FUNC(TCORE_LOG_FILE, ANSI_COLOR_LIGHTGRAY "<%s:%s> " ANSI_COLOR_NORMAL fmt "\n", __FILE__, __FUNCTION__, ##args); fflush(TCORE_LOG_FILE);}
124 #define warn(fmt,args...) TCORE_LOG_FUNC(TCORE_LOG_FILE, ANSI_COLOR_YELLOW "<%s:%s> " ANSI_COLOR_NORMAL fmt "\n", __FILE__, __FUNCTION__, ##args); fflush(TCORE_LOG_FILE);
125 #define err(fmt,args...) TCORE_LOG_FUNC(TCORE_LOG_FILE, ANSI_COLOR_LIGHTRED "<%s:%s> " ANSI_COLOR_NORMAL fmt "\n", __FILE__, __FUNCTION__, ##args); fflush(TCORE_LOG_FILE);
126 #define fatal(fmt,args...) TCORE_LOG_FUNC(TCORE_LOG_FILE, ANSI_COLOR_LIGHTRED "<%s:%s> " ANSI_COLOR_NORMAL fmt "\n", __FILE__, __FUNCTION__, ##args); fflush(TCORE_LOG_FILE);