Skip to content

Commit 5cfdf74

Browse files
committed
boost(Logging): Improve logging Switch foreground feature for better debugging
1 parent 28b09f6 commit 5cfdf74

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

SoundSwitch.Audio.Manager/AudioSwitcher.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@ public void SwitchTo(string deviceId, ERole role)
108108
/// <param name="processId">ProcessID of the process</param>
109109
public void SwitchProcessTo(string deviceId, ERole role, EDataFlow flow, uint processId)
110110
{
111+
var processName = "";
112+
try
113+
{
114+
var process = Process.GetProcessById((int)processId);
115+
processName = process.ProcessName;
116+
}
117+
catch (Exception e)
118+
{
119+
Trace.TraceError($"Can't get process info: {e}");
120+
}
121+
Trace.TraceInformation($"Attempt to switch [{processId}:{processName}] to {deviceId}");
111122
var roles = new[]
112123
{
113124
ERole.eConsole,
@@ -128,7 +139,7 @@ public void SwitchProcessTo(string deviceId, ERole role, EDataFlow flow, uint pr
128139
var currentEndpoint = roles.Select(eRole => ExtendPolicyClient.GetDefaultEndPoint(flow, eRole, processId)).FirstOrDefault(endpoint => !string.IsNullOrEmpty(endpoint));
129140
if (deviceId.Equals(currentEndpoint))
130141
{
131-
Trace.WriteLine($"Default endpoint for {processId} already {deviceId}");
142+
Trace.WriteLine($"Default endpoint for [{processId}:{processName}] already {deviceId}");
132143
return;
133144
}
134145

0 commit comments

Comments
 (0)