From 90390302d5ca7056fc679efe5aa01805a567e83a Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 26 Oct 2016 15:12:14 -0700 Subject: [PATCH] Make "adb logcat" pass $ANDROID_LOG_TAGS through again. But not for Windows, because even dealing with environment variables is too hard there (and no Windows user has complained yet). Bug: http://b/30184452 Test: manual Change-Id: I2d60049ed0049a9532414a7cdecbd0687e06aba7 --- adb/adb_trace.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/adb/adb_trace.cpp b/adb/adb_trace.cpp index 369dec963..002d06116 100644 --- a/adb/adb_trace.cpp +++ b/adb/adb_trace.cpp @@ -155,7 +155,24 @@ void adb_trace_init(char** argv) { } #endif +#if !defined(_WIN32) + // adb historically ignored $ANDROID_LOG_TAGS but passed it through to logcat. + // If set, move it out of the way so that libbase logging doesn't try to parse it. + std::string log_tags; + char* ANDROID_LOG_TAGS = getenv("ANDROID_LOG_TAGS"); + if (ANDROID_LOG_TAGS) { + log_tags = ANDROID_LOG_TAGS; + unsetenv("ANDROID_LOG_TAGS"); + } +#endif + android::base::InitLogging(argv, &AdbLogger); + +#if !defined(_WIN32) + // Put $ANDROID_LOG_TAGS back so we can pass it to logcat. + if (!log_tags.empty()) setenv("ANDROID_LOG_TAGS", log_tags.c_str(), 1); +#endif + setup_trace_mask(); VLOG(ADB) << adb_version();