2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __STORAGE_ADAPTOR_LOG_H__
18 #define __STORAGE_ADAPTOR_LOG_H__
22 * First you need to set platform logging on the device:
24 * # dlogctrl set platformlog 1
26 * After reboot you are able to see logs from this application, when you launch dlogutil with a proper filter e.g.:
28 * # dlogutil STORAGE_ADAPTOR:D
30 * You may use different logging levels as: D (debug), I (info), W (warning), E (error) or F (fatal).
31 * Higher level messages are included by default e.g. dlogutil CLOUDBOX:W prints warnings but also errors and fatal messages.
35 #include <linux/unistd.h>
37 /* These defines must be located before #include <dlog.h> */
38 #define TIZEN_ENGINEER_MODE
39 // TODO: Investigate why this macro is defined somewhere else
40 #ifndef TIZEN_DEBUG_ENABLE
41 #define TIZEN_DEBUG_ENABLE
47 /* Literal to filter logs from dlogutil */
48 #define LOG_TAG "STORAGE_ADAPTOR"
55 #endif /* __cplusplus */
60 #define FONT_COLOR_RESET "\033[0m"
61 #define FONT_COLOR_BLACK "\033[30m" /* Black */
62 #define FONT_COLOR_RED "\033[31m" /* Red */
63 #define FONT_COLOR_GREEN "\033[32m" /* Green */
64 #define FONT_COLOR_YELLOW "\033[33m" /* Yellow */
65 #define FONT_COLOR_BLUE "\033[34m" /* Blue */
66 #define FONT_COLOR_PURPLE "\033[35m" /* Purple */
67 #define FONT_COLOR_CYAN "\033[36m" /* Cyan */
68 #define FONT_COLOR_WHITE "\033[37m" /* White */
69 #define FONT_COLOR_BOLDBLACK "\033[1m\033[30m" /* Bold Black */
70 #define FONT_COLOR_BOLDRED "\033[1m\033[31m" /* Bold Red */
71 #define FONT_COLOR_BOLDGREEN "\033[1m\033[32m" /* Bold Green */
72 #define FONT_COLOR_BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */
73 #define FONT_COLOR_BOLDBLUE "\033[1m\033[34m" /* Bold Blue */
74 #define FONT_COLOR_BOLDPURPLE "\033[1m\033[35m" /* Bold Purple */
75 #define FONT_COLOR_BOLDCYAN "\033[1m\033[36m" /* Bold Cyan */
76 #define FONT_COLOR_BOLDWHITE "\033[1m\033[37m" /* Bold White */
81 #define storage_adaptor_gettid() syscall(__NR_gettid)
84 * @brief Macro for returning value if expression is satisfied
85 * @param[in] expr Expression to be checked
86 * @param[out] val Value to be returned when expression is true
88 #define storage_adaptor_retv_if(expr, val) do { \
90 LOGE(FONT_COLOR_PURPLE"[%d]"FONT_COLOR_RESET, storage_adaptor_gettid()); \
96 * @brief Prints debug messages
97 * @param[in] fmt Format of data to be displayed
98 * @param[in] args Arguments to be displayed
100 #define storage_adaptor_debug(fmt, arg...) do { \
101 LOGD(FONT_COLOR_GREEN"[%d]"fmt""FONT_COLOR_RESET, storage_adaptor_gettid(), ##arg); \
105 * @brief Prints info messages
106 * @param[in] fmt Format of data to be displayed
107 * @param[in] args Arguments to be displayed
109 #define storage_adaptor_info(fmt, arg...) do { \
110 LOGI(FONT_COLOR_BLUE"[%d]"fmt""FONT_COLOR_RESET, storage_adaptor_gettid() ,##arg); \
114 * @brief Prints warning messages
115 * @param[in] fmt Format of data to be displayed
116 * @param[in] args Arguments to be displayed
118 #define storage_adaptor_warning(fmt, arg...) do { \
119 LOGW(FONT_COLOR_YELLOW"[%d]"fmt""FONT_COLOR_RESET,storage_adaptor_gettid(), ##arg); \
123 * @brief Prints error messages
124 * @param[in] fmt Format of data to be displayed
125 * @param[in] args Arguments to be displayed
127 #define storage_adaptor_error(fmt, arg...) do { \
128 LOGE(FONT_COLOR_RED"[%d]"fmt""FONT_COLOR_RESET,storage_adaptor_gettid(), ##arg); \
132 * @brief Prints fatal messages
133 * @param[in] fmt Format of data to be displayed
134 * @param[in] args Arguments to be displayed
136 #define storage_adaptor_fatal(fmt, arg...) do { \
137 LOGF(FONT_COLOR_BOLDRED"[%d]"fmt""FONT_COLOR_RESET,storage_adaptor_gettid(), ##arg); \
141 * @brief Prints debug message on entry to particular function
142 * @param[in] fmt Format of data to be displayed
143 * @param[in] args Arguments to be displayed
145 #define storage_adaptor_debug_func(fmt, arg...) do { \
146 LOGD(FONT_COLOR_CYAN"[%d]"fmt""FONT_COLOR_RESET, storage_adaptor_gettid(), ##arg); \
150 * @brief Prints debug message on entry to particular function
151 * @param[in] fmt Format of data to be displayed
152 * @param[in] args Arguments to be displayed
154 #define storage_adaptor_debug_secure(fmt, arg...) do { \
155 SECURE_LOGD(FONT_COLOR_CYAN"[%d]"fmt""FONT_COLOR_RESET, storage_adaptor_gettid(), ##arg); \
158 #define storage_adaptor_check_param_equal(compare, val, ret_val, exception_handling) {\
159 if ( compare == val ) {\
160 LOGD(FONT_COLOR_PURPLE "[%d]<Line :%d>" "Parameter Check catched (equal) \n : Expected(%p) Value(%p)" FONT_COLOR_RESET, storage_adaptor_gettid(), __LINE__, compare, val);\
166 #define plugin_req_enter() do { \
167 storage_adaptor_info("[ENTER] plugin API call -)) -)) -)) -)) -)) -)) -)) -)) -)) -))"); \
170 #define plugin_req_exit(ret, plugin, error) do { \
171 storage_adaptor_info("[EXIT] plugin API called (%d) ((- ((- ((- ((- ((- ((- ((- ((- ((- ((-", (int)(ret)); \
174 storage_adaptor_error("plugin issued error (%lld) (%s)", (long long int)((*error)->code), (char *)((*error)->msg)); \
175 char *tem = g_strdup_printf("[PLUGIN_ERROR] URI(%s), MSG(%s)", (char *)((plugin)->handle->plugin_uri), (char *)((*error)->msg)); \
177 free((*error)->msg); \
178 (*error)->msg = tem; \
184 #define plugin_req_exit_void() do { \
185 storage_adaptor_info("[EXIT] plugin API called ((- ((- ((- ((- ((- ((- ((- ((- ((- ((-"); \
190 #endif /* __cplusplus */
192 #endif /* __STORAGE_ADAPTOR_LOG_H__ */