blob: b4155dffd734ea0565e36306bbf8deba6aebafa8 [file] [log] [blame]
leozwangd3fc15f2014-07-29 12:50:02 -07001/*
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
Yabin Cui7a3f8d62015-09-02 17:44:28 -070020#include <base/logging.h>
21#include <base/stringprintf.h>
leozwangd3fc15f2014-07-29 12:50:02 -070022
leozwangd3fc15f2014-07-29 12:50:02 -070023/* IMPORTANT: if you change the following list, don't
24 * forget to update the corresponding 'tags' table in
25 * the adb_trace_init() function implemented in adb.c
26 */
Elliott Hughes2d4121c2015-04-17 09:47:42 -070027enum AdbTrace {
leozwangd3fc15f2014-07-29 12:50:02 -070028 TRACE_ADB = 0, /* 0x001 */
29 TRACE_SOCKETS,
30 TRACE_PACKETS,
31 TRACE_TRANSPORT,
32 TRACE_RWX, /* 0x010 */
33 TRACE_USB,
34 TRACE_SYNC,
35 TRACE_SYSDEPS,
36 TRACE_JDWP, /* 0x100 */
37 TRACE_SERVICES,
38 TRACE_AUTH,
39 TRACE_FDEVENT,
David Pursell80f67022015-08-28 15:08:49 -070040 TRACE_SHELL
Elliott Hughesbd4b1fa2015-08-28 14:46:33 -070041};
leozwangd3fc15f2014-07-29 12:50:02 -070042
Dan Albert9313c0d2015-05-21 13:58:50 -070043extern int adb_trace_mask;
44extern unsigned char adb_trace_output_count;
45void adb_trace_init(char**);
leozwangd3fc15f2014-07-29 12:50:02 -070046
Yabin Cui7a3f8d62015-09-02 17:44:28 -070047#define ADB_TRACING ((adb_trace_mask & (1 << TRACE_TAG)) != 0)
leozwangd3fc15f2014-07-29 12:50:02 -070048
Yabin Cui7a3f8d62015-09-02 17:44:28 -070049// You must define TRACE_TAG before using this macro.
50#define D(...) \
Elliott Hughesbd4b1fa2015-08-28 14:46:33 -070051 do { \
52 if (ADB_TRACING) { \
Yabin Cui7a3f8d62015-09-02 17:44:28 -070053 LOG(INFO) << android::base::StringPrintf(__VA_ARGS__); \
Elliott Hughesbd4b1fa2015-08-28 14:46:33 -070054 } \
leozwangd3fc15f2014-07-29 12:50:02 -070055 } while (0)
leozwangd3fc15f2014-07-29 12:50:02 -070056
leozwangd3fc15f2014-07-29 12:50:02 -070057#endif /* __ADB_TRACE_H */