summaryrefslogtreecommitdiff
path: root/media/eco/include/eco/ECODebug.h
blob: ff0e8b5b9cf1fd458b659efa902590eb2c4e8d96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ANDROID_MEDIA_ECO_DEBUG_H_
#define ANDROID_MEDIA_ECO_DEBUG_H_

#include <cutils/atomic.h>
#include <cutils/properties.h>

#include "ECOData.h"

namespace android {
namespace media {
namespace eco {

static const char* kDisableEcoServiceProperty = "vendor.media.ecoservice.disable";
static const char* kDebugLogsLevelProperty = "vendor.media.ecoservice.log.level";
static const char* kDebugLogStats = "vendor.media.ecoservice.log.stats";
static const char* kDebugLogStatsSize = "vendor.media.ecoservice.log.stats.size";
static const char* kDebugLogInfos = "vendor.media.ecoservice.log.info";
static const char* kDebugLogInfosSize = "vendor.media.ecoservice.log.info.size";

// A debug variable that should only be accessed by ECOService through updateLogLevel. It is rare
// that this variable will have race condition. But if so, it is ok as this is just for debugging.
extern uint32_t gECOLogLevel;

enum ECOLogLevel : uint32_t {
    ECO_MSGLEVEL_DEBUG = 0x01,    ///< debug logs
    ECO_MSGLEVEL_VERBOSE = 0x02,  ///< very detailed logs
    ECO_MSGLEVEL_ALL = 0x03,      ///< both debug logs and detailed logs
};

#define ECOLOGV(format, args...) ALOGD_IF((gECOLogLevel & ECO_MSGLEVEL_VERBOSE), format, ##args)
#define ECOLOGD(format, args...) ALOGD_IF((gECOLogLevel & ECO_MSGLEVEL_DEBUG), format, ##args)
#define ECOLOGI(format, args...) ALOGI(format, ##args)
#define ECOLOGW(format, args...) ALOGW(format, ##args)
#define ECOLOGE(format, args...) ALOGE(format, ##args)

void updateLogLevel();

// Convenience methods for constructing binder::Status objects for error returns
#define STATUS_ERROR(errorCode, errorString)  \
    binder::Status::fromServiceSpecificError( \
            errorCode, String8::format("%s:%d: %s", __FUNCTION__, __LINE__, errorString))

#define STATUS_ERROR_FMT(errorCode, errorString, ...) \
    binder::Status::fromServiceSpecificError(         \
            errorCode,                                \
            String8::format("%s:%d: " errorString, __FUNCTION__, __LINE__, __VA_ARGS__))

}  // namespace eco
}  // namespace media
}  // namespace android

#endif  // ANDROID_MEDIA_ECO_DEBUG_H_