Stephen Hines | 5b94819 | 2012-05-03 12:26:56 -0700 | [diff] [blame] | 1 | /* |
Stephen Hines | 2f6a493 | 2012-05-03 12:27:13 -0700 | [diff] [blame] | 2 | * Copyright 2010, The Android Open Source Project |
Stephen Hines | 5b94819 | 2012-05-03 12:26:56 -0700 | [diff] [blame] | 3 | * |
| 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 |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 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. |
| 15 | */ |
| 16 | |
Stephen Hines | 2f6a493 | 2012-05-03 12:27:13 -0700 | [diff] [blame] | 17 | #ifndef BCC_DEBUGHELPER_H |
| 18 | #define BCC_DEBUGHELPER_H |
Stephen Hines | 5b94819 | 2012-05-03 12:26:56 -0700 | [diff] [blame] | 19 | |
Stephen Hines | 2f6a493 | 2012-05-03 12:27:13 -0700 | [diff] [blame] | 20 | #include "Config.h" |
Stephen Hines | 5b94819 | 2012-05-03 12:26:56 -0700 | [diff] [blame] | 21 | |
Stephen Hines | 802d138 | 2012-05-03 12:31:09 -0700 | [diff] [blame^] | 22 | #if USE_LOGGER |
| 23 | |
Stephen Hines | 5b94819 | 2012-05-03 12:26:56 -0700 | [diff] [blame] | 24 | #define LOG_TAG "bcc" |
| 25 | #include <cutils/log.h> |
| 26 | |
Stephen Hines | 802d138 | 2012-05-03 12:31:09 -0700 | [diff] [blame^] | 27 | #else // !USE_LOGGER |
| 28 | |
| 29 | #undef ALOGV |
| 30 | #undef ALOGI |
| 31 | #undef ALOGD |
| 32 | #undef ALOGW |
| 33 | #undef ALOGE |
| 34 | #undef LOGA |
| 35 | |
| 36 | #define ALOGV(...) |
| 37 | #define ALOGI(...) |
| 38 | #define ALOGD(...) |
| 39 | #define ALOGW(...) |
| 40 | #define ALOGE(...) |
| 41 | #define LOGA(...) |
| 42 | |
| 43 | #endif |
| 44 | |
| 45 | |
Stephen Hines | 5b94819 | 2012-05-03 12:26:56 -0700 | [diff] [blame] | 46 | #if !USE_FUNC_LOGGER |
| 47 | |
| 48 | #define BCC_FUNC_LOGGER() |
| 49 | |
| 50 | #else // USE_FUNC_LOGGER |
| 51 | |
| 52 | #if defined(__cplusplus) |
| 53 | namespace bcc { |
| 54 | class FuncLogger { |
| 55 | private: |
| 56 | char const *mFuncName; |
| 57 | |
| 58 | public: |
| 59 | FuncLogger(char const *name) : mFuncName(name) { |
| 60 | ALOGD("---> BEGIN: libbcc [ %s ]\n", name); |
| 61 | } |
| 62 | |
| 63 | ~FuncLogger() { |
| 64 | ALOGD("---> END: libbcc [ %s ]\n", mFuncName); |
| 65 | } |
| 66 | }; |
| 67 | } // namespace bcc |
| 68 | |
| 69 | #define BCC_FUNC_LOGGER() bcc::FuncLogger XX__FuncLogger(__func__) |
| 70 | #endif |
| 71 | |
| 72 | #endif |
| 73 | |
Stephen Hines | 2f6a493 | 2012-05-03 12:27:13 -0700 | [diff] [blame] | 74 | #endif // BCC_DEBUGHELPER_H |