1 /* 2 * Copyright (C) 2014 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 __ADB_TRACE_H 18 #define __ADB_TRACE_H 19 20 #include <string> 21 22 #include <android-base/logging.h> 23 #include <android-base/stringprintf.h> 24 25 /* IMPORTANT: if you change the following list, don't 26 * forget to update the corresponding 'tags' table in 27 * the setup_trace_mask() function implemented in adb_trace.cpp. 28 */ 29 enum AdbTrace { 30 ADB = 0, /* 0x001 */ 31 SOCKETS, 32 PACKETS, 33 TRANSPORT, 34 RWX, /* 0x010 */ 35 USB, 36 SYNC, 37 SYSDEPS, 38 JDWP, /* 0x100 */ 39 SERVICES, 40 AUTH, 41 FDEVENT, 42 SHELL, 43 INCREMENTAL, 44 MDNS, 45 MDNS_STACK, 46 NUM_TRACES, 47 }; 48 49 #define VLOG_IS_ON(TAG) \ 50 ((adb_trace_mask & (1 << (TAG))) != 0) 51 52 #define VLOG(TAG) \ 53 if (LIKELY(!VLOG_IS_ON(TAG))) \ 54 ; \ 55 else \ 56 LOG(DEBUG) 57 58 // You must define TRACE_TAG before using this macro. 59 #define D(...) \ 60 VLOG(TRACE_TAG) << android::base::StringPrintf(__VA_ARGS__) 61 62 63 extern int adb_trace_mask; 64 void adb_trace_init(char**); 65 void adb_trace_enable(AdbTrace trace_tag); 66 std::string get_trace_setting(); 67 68 #endif /* __ADB_TRACE_H */ 69