1 /* 2 * Copyright (C) 2019 The Android Open Source Project 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 17 #ifndef ANDROID_MEDIA_ECO_DEBUG_H_ 18 #define ANDROID_MEDIA_ECO_DEBUG_H_ 19 20 #include <cutils/atomic.h> 21 #include <cutils/properties.h> 22 23 #include "ECOData.h" 24 25 namespace android { 26 namespace media { 27 namespace eco { 28 29 static const char* kDisableEcoServiceProperty = "vendor.media.ecoservice.disable"; 30 static const char* kDebugLogsLevelProperty = "vendor.media.ecoservice.log.level"; 31 static const char* kDebugLogStats = "vendor.media.ecoservice.log.stats"; 32 static const char* kDebugLogStatsSize = "vendor.media.ecoservice.log.stats.size"; 33 static const char* kDebugLogInfos = "vendor.media.ecoservice.log.info"; 34 static const char* kDebugLogInfosSize = "vendor.media.ecoservice.log.info.size"; 35 36 // A debug variable that should only be accessed by ECOService through updateLogLevel. It is rare 37 // that this variable will have race condition. But if so, it is ok as this is just for debugging. 38 extern uint32_t gECOLogLevel; 39 40 enum ECOLogLevel : uint32_t { 41 ECO_MSGLEVEL_DEBUG = 0x01, ///< debug logs 42 ECO_MSGLEVEL_VERBOSE = 0x02, ///< very detailed logs 43 ECO_MSGLEVEL_ALL = 0x03, ///< both debug logs and detailed logs 44 }; 45 46 #define ECOLOGV(format, args...) ALOGD_IF((gECOLogLevel & ECO_MSGLEVEL_VERBOSE), format, ##args) 47 #define ECOLOGD(format, args...) ALOGD_IF((gECOLogLevel & ECO_MSGLEVEL_DEBUG), format, ##args) 48 #define ECOLOGI(format, args...) ALOGI(format, ##args) 49 #define ECOLOGW(format, args...) ALOGW(format, ##args) 50 #define ECOLOGE(format, args...) ALOGE(format, ##args) 51 52 void updateLogLevel(); 53 54 // Convenience methods for constructing binder::Status objects for error returns 55 #define STATUS_ERROR(errorCode, errorString) \ 56 binder::Status::fromServiceSpecificError( \ 57 errorCode, String8::format("%s:%d: %s", __FUNCTION__, __LINE__, errorString)) 58 59 #define STATUS_ERROR_FMT(errorCode, errorString, ...) \ 60 binder::Status::fromServiceSpecificError( \ 61 errorCode, \ 62 String8::format("%s:%d: " errorString, __FUNCTION__, __LINE__, __VA_ARGS__)) 63 64 } // namespace eco 65 } // namespace media 66 } // namespace android 67 68 #endif // ANDROID_MEDIA_ECO_DEBUG_H_ 69