Skip to content

Commit

Permalink
Implemented diagnose command
Browse files Browse the repository at this point in the history
  • Loading branch information
inga-lovinde committed Aug 20, 2020
1 parent bcd3960 commit 9680c5d
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
27 changes: 27 additions & 0 deletions RadeonResetBugFixService/MainHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,32 @@ public void HandleShutdown(string reason)
}
}
}

public void HandleDiagnose(string reason)
{
using (var fileLogger = new FileLogger(this.LogFilename))
{
using (ILogger logger = new TaskLoggerWrapper(fileLogger, "Diagnose"))
{
logger.Log($"Reason: {reason}");
try
{
lock (this.Mutex)
{
TasksProcessor.ProcessTasks(
logger,
new ITask[]
{
new ListDevicesTask(),
});
}
}
catch (Exception e)
{
logger.LogError(e.ToString());
}
}
}
}
}
}
11 changes: 11 additions & 0 deletions RadeonResetBugFixService/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ private static void MainConsole(string[] args)
{
DoShutdown();
}
else if (command.Equals("diagnose", StringComparison.OrdinalIgnoreCase))
{
DoDiagnose();
}
else
{
ShowHelp();
Expand All @@ -92,6 +96,8 @@ private static void ShowHelp()
Console.WriteLine("\t\tPerforms startup sequence (development command, does not affect services)");
Console.WriteLine($"\t{exeName} shutdown");
Console.WriteLine("\t\tPerforms shutdown sequence (development command, does not affect services)");
Console.WriteLine($"\t{exeName} diagnose");
Console.WriteLine("\t\tPerforms diagnose (see result file in logs folder)");
}

private static void DoInstall()
Expand Down Expand Up @@ -136,5 +142,10 @@ private static void DoShutdown()
{
new MainHandler().HandleShutdown("Program.DoShutdown");
}

private static void DoDiagnose()
{
new MainHandler().HandleDiagnose("Program.DoDiagnose");
}
}
}
1 change: 1 addition & 0 deletions RadeonResetBugFixService/RadeonResetBugFixService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<Compile Include="Tasks\EnableBasicDisplayStartupTask.cs" />
<Compile Include="Tasks\FixMonitorTask.cs" />
<Compile Include="Tasks\LastResortDevicesRestoreTask.cs" />
<Compile Include="Tasks\ListDevicesTask.cs" />
<Compile Include="Tasks\SleepTask.cs" />
<Compile Include="ThirdParty\MonitorChanger.cs" />
<Compile Include="ThirdParty\ServiceHelpers.cs" />
Expand Down
19 changes: 19 additions & 0 deletions RadeonResetBugFixService/Tasks/ListDevicesTask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace RadeonResetBugFixService.Tasks
{
using System.Linq;
using Contracts;
using Devices;

class ListDevicesTask : ITask
{
string ITask.TaskName => "Listing devices";

void ITask.Run(ILogger logger)
{
foreach (var device in DeviceHelper.GetDevices().ToArray())
{
logger.Log($"Found device {device.Description}: manufacturer='{device.Manufacturer}', service='{device.Service}', class='{device.ClassName}'");
}
}
}
}

0 comments on commit 9680c5d

Please sign in to comment.