3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
5 * This file is part of msg-service.
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 * Sangkoo Kim <sangkoo.kim@samsung.com>
9 * Seunghwan Lee <sh.cat.lee@samsung.com>
10 * SoonMin Jung <sm0415.jung@samsung.com>
11 * Jae-Young Lee <jy4710.lee@samsung.com>
12 * KeeBum Kim <keebum.kim@samsung.com>
14 * PROPRIETARY/CONFIDENTIAL
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
31 #ifndef __MSG_DEBUG_H__
32 #define __MSG_DEBUG_H__
34 /*==================================================================================================
36 ==================================================================================================*/
37 #include <sys/types.h>
44 #include "MsgCmdTypes.h"
51 /*==================================================================================================
53 ==================================================================================================*/
54 #define USER_TAG "MSG_FW"
60 /*==================================================================================================
62 ==================================================================================================*/
66 #if defined(DLOG_ENABLE)
68 #define MSG_FATAL(fmt, ...) \
71 SLOG(LOG_ERROR, USER_TAG, "[%s: %s(): %d] ERROR << " fmt " >>\n\n", rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__, ##__VA_ARGS__);\
74 #define MSG_DEBUG(fmt, ...)\
77 SLOG(LOG_DEBUG, USER_TAG, "[%s: %s(): %d] " fmt"\n\n", rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__, ##__VA_ARGS__);\
83 SLOG(LOG_DEBUG, USER_TAG, "[%s: %s(): %d] BEGIN >>>> \n\n", rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__ );\
89 SLOG(LOG_DEBUG, USER_TAG, "[%s: %s(): %d] END <<<< \n\n", rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__ );\
93 #define MSG_PROFILE_BEGIN(pfid) \
94 unsigned int __prf_l1_##pfid = __LINE__; \
95 struct timeval __prf_1_##pfid; \
96 struct timeval __prf_2_##pfid; \
98 gettimeofday(&__prf_1_##pfid, 0); \
101 #define MSG_PROFILE_END(pfid) \
102 unsigned int __prf_l2_##pfid = __LINE__;\
104 gettimeofday(&__prf_2_##pfid, 0);\
105 long __ds = __prf_2_##pfid.tv_sec - __prf_1_##pfid.tv_sec;\
106 long __dm = __prf_2_##pfid.tv_usec - __prf_1_##pfid.tv_usec;\
107 if ( __dm < 0 ) { __ds--; __dm = 1000000 + __dm; } \
108 SLOG(LOG_DEBUG, USER_TAG, "**PROFILE** [MSGFW: %s: %s() %u ~ %u] " #pfid \
109 " -> Elapsed Time: %u.%06u seconds\n", \
110 rindex(__FILE__, '/')+1, \
114 (unsigned int)(__ds), \
115 (unsigned int)(__dm)); \
118 #elif defined(LOG_ENABLE)
120 #define MSG_FATAL(fmt, ...) \
123 printf("\n[%d] [MSGFW: %s: %s(): %d] *FAILED* << " fmt" >>\n", get_tid(), rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__, ##__VA_ARGS__);\
126 #define MSG_DEBUG(fmt, ...) \
129 printf("\n[%d] [MSGFW: %s: %s(): %d] " fmt"\n", get_tid(), rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__, ##__VA_ARGS__);\
132 #define MSG_BEGIN() \
135 printf("\n[%d] BEGIN >>>> %s() at [MSGFW: %s: %d]\n", get_tid(),__FUNCTION__, rindex(__FILE__, '/')+1, __LINE__ );\
141 printf("\n[%d] END <<<< %s() at [MSGFW: %s: %d]\n", get_tid(), __FUNCTION__, rindex(__FILE__, '/')+1, __LINE__); \
145 #define MSG_PROFILE_BEGIN(pfid) \
146 unsigned int __prf_l1_##pfid = __LINE__; \
147 struct timeval __prf_1_##pfid; \
148 struct timeval __prf_2_##pfid; \
150 gettimeofday(&__prf_1_##pfid, 0); \
153 #define MSG_PROFILE_END(pfid) \
154 unsigned int __prf_l2_##pfid = __LINE__;\
156 gettimeofday(&__prf_2_##pfid, 0);\
157 long __ds = __prf_2_##pfid.tv_sec - __prf_1_##pfid.tv_sec;\
158 long __dm = __prf_2_##pfid.tv_usec - __prf_1_##pfid.tv_usec;\
159 if ( __dm < 0 ) { __ds--; __dm = 1000000 + __dm; } \
160 printf("**PROFILE** [MSGFW: %s: %s() %u ~ %u] " #pfid \
161 " -> Elapsed Time: %u.%06u seconds\n", \
162 rindex(__FILE__, '/')+1, \
166 (unsigned int)(__ds), \
167 (unsigned int)(__dm)); \
172 #define MSG_FATAL(fmt, ...)
173 #define MSG_DEBUG(fmt, ...)
177 #define MSG_PROFILE_BEGIN(pfid)
178 #define MSG_PROFILE_END(pfid)
182 const char * MsgDbgCmdStr(MSG_CMD_TYPE_T cmdType);
183 const char * MsgDbgEvtStr(MSG_EVENT_TYPE_T evtType);
185 #endif //__MSG_DEBUG_H__