Tizen 2.0 Release
[framework/appfw/libslp-db-util.git] / include / db-util-debug.h
1 /*
2  * libslp-db-util
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Hakjoo Ko <hakjoo.ko@samsung.com>
7  *
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  */
21
22 #ifndef __DB_UTIL_DEBUG_H_
23 #define __DB_UTIL_DEBUG_H_
24 #include <stdio.h>
25
26 #ifdef DB_UTIL_USING_PLATFORM_DBG
27         #include <dlog.h>
28         #ifdef LOG_TAG
29                 #undef LOG_TAG
30         #endif
31         #define LOG_TAG "DBUTIL"
32 #endif
33
34 #ifdef DB_UTIL_ENABLE_TRACE
35
36         #ifdef DB_UTIL_USING_PLATFORM_DBG
37
38                 #define DB_UTIL_TRACE_DEBUG LOGD
39                 #define DB_UTIL_TRACE_WARNING LOGW
40                 #define DB_UTIL_TRACE_ERROR LOGE
41
42         #else
43
44                 #define DB_UTIL_TRACE_DEBUG(fmt, arg...) \
45                         do {\
46                                 fprintf(stderr,"[DBUTIL]\033[0;32mDEBUG: " fmt "\033[0m\t%s:%d\n", ##arg, strrchr(__FILE__, '/')+1, __LINE__);\
47                         }while(0);
48
49                 #define DB_UTIL_TRACE_WARNING(fmt, arg...) \
50                         do {\
51                                 fprintf(stderr,"[DBUTIL]\033[0;33mWARRING: " fmt "\033[0m\t%s:%d\n", ##arg, strrchr(__FILE__, '/')+1, __LINE__);\
52                         }while(0);
53
54                 #define DB_UTIL_TRACE_ERROR(fmt, arg...) \
55                         do {\
56                                 fprintf(stderr, "[DBUTIL]\033[0;31mERROR: " fmt "\033[0m\t%s:%d\n", ##arg, strrchr(__FILE__, '/')+1, __LINE__);\
57                         }while(0);
58
59         #endif
60
61 #else
62
63         #define DB_UTIL_TRACE_DEBUG(fmt, arg...)
64         #define DB_UTIL_TRACE_WARNING(fmt, arg...)
65         #define DB_UTIL_TRACE_ERROR(fmt, arg...)
66
67 #endif
68 #endif /* __DB_UTIL_DEBUG_H_ */
69