• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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* kDebugLogsLevelProperty = "media.ecoservice.log.level";
30 static const char* kDebugLogStats = "media.ecoservice.log.stats";
31 static const char* kDebugLogStatsSize = "media.ecoservice.log.stats.size";
32 static const char* kDebugLogInfos = "media.ecoservice.log.info";
33 static const char* kDebugLogInfosSize = "media.ecoservice.log.info.size";
34 
35 // A debug variable that should only be accessed by ECOService through updateLogLevel. It is rare
36 // that this variable will have race condition. But if so, it is ok as this is just for debugging.
37 extern uint32_t gECOLogLevel;
38 
39 enum ECOLogLevel : uint32_t {
40     ECO_MSGLEVEL_DEBUG = 0x01,    ///< debug logs
41     ECO_MSGLEVEL_VERBOSE = 0x02,  ///< very detailed logs
42     ECO_MSGLEVEL_ALL = 0x03,      ///< both debug logs and detailed logs
43 };
44 
45 #define ECOLOGV(format, args...) ALOGD_IF((gECOLogLevel & ECO_MSGLEVEL_VERBOSE), format, ##args)
46 #define ECOLOGD(format, args...) ALOGD_IF((gECOLogLevel & ECO_MSGLEVEL_DEBUG), format, ##args)
47 #define ECOLOGI(format, args...) ALOGI(format, ##args)
48 #define ECOLOGW(format, args...) ALOGW(format, ##args)
49 #define ECOLOGE(format, args...) ALOGE(format, ##args)
50 
51 void updateLogLevel();
52 
53 // Convenience methods for constructing binder::Status objects for error returns
54 #define STATUS_ERROR(errorCode, errorString)  \
55     binder::Status::fromServiceSpecificError( \
56             errorCode, String8::format("%s:%d: %s", __FUNCTION__, __LINE__, errorString))
57 
58 #define STATUS_ERROR_FMT(errorCode, errorString, ...) \
59     binder::Status::fromServiceSpecificError(         \
60             errorCode,                                \
61             String8::format("%s:%d: " errorString, __FUNCTION__, __LINE__, __VA_ARGS__))
62 
63 }  // namespace eco
64 }  // namespace media
65 }  // namespace android
66 
67 #endif  // ANDROID_MEDIA_ECO_DEBUG_H_
68