Skip to content

Commit 5c54760

Browse files
only log what's requested by the user
1 parent c85f725 commit 5c54760

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/Tools/dotnet-dsrouter/ADBTcpRouterFactory.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,30 @@ public static void AdbRemovePortReverse(int localPort, int remotePort, bool owns
6666

6767
public static bool RunAdbCommandInternal(string command, string expectedOutput, int expectedExitCode, bool rethrow, ILogger logger)
6868
{
69+
void sdklogger(TraceLevel level, string message)
70+
{
71+
switch (level)
72+
{
73+
case TraceLevel.Off:
74+
// No logging for Off level
75+
break;
76+
case TraceLevel.Error:
77+
logger?.LogError(message);
78+
break;
79+
case TraceLevel.Warning:
80+
logger?.LogWarning(message);
81+
break;
82+
case TraceLevel.Info:
83+
logger?.LogInformation(message);
84+
break;
85+
case TraceLevel.Verbose:
86+
logger?.LogDebug(message);
87+
break;
88+
}
89+
};
90+
6991
//ANDROID_SDK_ROOT is deprecated
70-
string sdkRoot = Environment.GetEnvironmentVariable("ANDROID_HOME") ?? Environment.GetEnvironmentVariable("ANDROID_SDK_ROOT") ?? new AndroidSdkInfo().AndroidSdkPath;
92+
string sdkRoot = Environment.GetEnvironmentVariable("ANDROID_HOME") ?? Environment.GetEnvironmentVariable("ANDROID_SDK_ROOT") ?? new AndroidSdkInfo(logger: sdklogger).AndroidSdkPath;
7193
string adbTool = "adb";
7294

7395
if (!string.IsNullOrEmpty(sdkRoot))

0 commit comments

Comments
 (0)