TVSystemService JNI  0.10
HAL_error.h
1 /*****************************************************************************
2  * Copyright (c) TVStorm, Inc. http://www.tvstorm.com. All rights reserved.
3  * TVSTORM PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
4  *
5  * $LastChangedBy: skkim $
6  * $LastChangedDate: 2011-10-25 18:11:22 +0900 (화, 25 10월 2011) $
7  * $LastChangedRevision: 815 $
8  * Description:
9  * Note:
10  *****************************************************************************/
11 
12 #ifndef HALERROR_H_
13 #define HALERROR_H_
14 
15 typedef enum
16 {
17  // not defined yet (SKB)
18  HAL_ERROR = -1,
19  HAL_OK = 0,
20  HAL_ERROR_NOT_IMPLEMENTED,
21  HAL_ERROR_NOT_INITIALIZED,
22  HAL_ERROR_INVALID_PARAMS,
23 
24 }
25 THAL_Error;
26 
27 typedef enum
28 {
29  HAL_FALSE,
30  HAL_TRUE,
31 }
32 THAL_Bool;
33 
34 #ifndef FALSE
35 #define FALSE (HAL_FALSE)
36 #endif
37 
38 #ifndef TRUE
39 #define TRUE (HAL_TRUE)
40 #endif
41 
42 #ifndef L_ERROR
43 
44 #ifdef ANDROID
45  #include <android/log.h>
46 #endif
47 
48 
49 #ifdef LOG_TAG
50 
51  #ifdef ANDROID
52 
53  #define L_TRACE(...) \
54  FunctionLogger __flogger(__FILE__,__FUNCTION__,__LINE__);\
55  __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)
56 
57  #define L_DEBUG(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
58  #define L_WARN(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
59  #define L_ERROR(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
60 
61  #else // ANDROID
62 
63  #define L_TRACE(args...) do { printf("[TRACE] %s:%d: ",__FILE__, __LINE__); printf(args); printf("\n"); } while(0)
64  #define L_DEBUG(args...) do { printf("[DEBUG] %s:%d: ",__FILE__, __LINE__); printf(args); printf("\n"); } while(0)
65  #define L_WARN(args...) do { printf("[WARN ] %s:%d: ",__FILE__, __LINE__); printf(args); printf("\n"); } while(0)
66  #define L_ERROR(args...) do { printf("[ERROR] %s:%d: ",__FILE__, __LINE__); printf(args); printf("\n"); } while(0)
67 
68  #endif // ANDROID
69 
70 #else
71 
72  #define L_TRACE(...) do { } while(0)
73  #define L_DEBUG(...) do { } while(0)
74  #define L_WARN(...) do { } while(0)
75 
76 // L_ERROR is always enabled
77 
78 #ifdef ANDROID
79 #ifdef LOG_TAG
80  #define L_ERROR(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
81 #else
82  #define L_ERROR(...) __android_log_print(ANDROID_LOG_ERROR, __FILE__, __VA_ARGS__)
83 #endif
84 #else
85  #define L_ERROR(args...) do { printf("[ERROR] %s:%d: ",__FILE__, __LINE__); printf(args); printf("\n"); } while(0)
86 #endif
87 
88 #endif
89 
91 {
92 public:
93  FunctionLogger(const char * file, const char * func, const int line)
94  : m_file(file)
95  , m_func(func)
96  , m_line(line)
97  {
98  L_DEBUG("%s:%d:%s() >> begin", m_file, m_line, m_func);
99  }
100 
101  ~FunctionLogger()
102  {
103  L_DEBUG("%s:%d:%s() << end", m_file, m_line, m_func);
104  }
105 
106 private:
107  const char * m_file;
108  const char * m_func;
109  const int m_line;
110 };
111 
112 #endif // L_ERROR
113 
114 #endif // HALERROR_H_
Definition: HAL_error.h:90