mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Fixed LogReporter
Fixed LogReporter error introduced by my earlier modifications of HeliosPlus due to ProfileItem object changes. This messed up the LogReporter writing logic which in turn made log files balloon to multiple GB in size! Also added capture of the various JSON files that are used to store settings so that we can help fix JSON errors.
This commit is contained in:
parent
eb38e88dc5
commit
1903956b85
@ -8,7 +8,7 @@
|
|||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<ProjectGuid>{76DF2BCF-911B-4820-B63E-8F3468DB5E79}</ProjectGuid>
|
<ProjectGuid>{76DF2BCF-911B-4820-B63E-8F3468DB5E79}</ProjectGuid>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<RootNamespace>HeliosPlus.Reporting</RootNamespace>
|
<RootNamespace>HeliosPlus.LogReporter</RootNamespace>
|
||||||
<AssemblyName>HeliosPlus.LogReporter</AssemblyName>
|
<AssemblyName>HeliosPlus.LogReporter</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
@ -42,6 +42,7 @@
|
|||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<UseVSHostingProcess>true</UseVSHostingProcess>
|
<UseVSHostingProcess>true</UseVSHostingProcess>
|
||||||
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
Before Width: | Height: | Size: 457 KiB After Width: | Height: | Size: 457 KiB |
@ -11,20 +11,20 @@ using HeliosPlus.Shared;
|
|||||||
using NvAPIWrapper.GPU;
|
using NvAPIWrapper.GPU;
|
||||||
using NvAPIWrapper.Mosaic;
|
using NvAPIWrapper.Mosaic;
|
||||||
|
|
||||||
namespace HeliosPlus.Reporting
|
namespace HeliosPlus.LogReporter
|
||||||
{
|
{
|
||||||
internal class Program
|
internal class Program
|
||||||
{
|
{
|
||||||
private static StreamWriter _writer;
|
private static StreamWriter _writer;
|
||||||
internal static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "HeliosPlus");
|
internal static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "HeliosPlus");
|
||||||
|
|
||||||
private static void Dump<T>(
|
private static void DumpObject<T>(
|
||||||
IEnumerable<T> items,
|
IEnumerable<T> items,
|
||||||
string title,
|
string title,
|
||||||
Tuple<Func<T, object>, string>[] actions = null,
|
Tuple<Func<T, object>, string>[] actions = null,
|
||||||
int deepIn = 0)
|
int deepIn = 0)
|
||||||
{
|
{
|
||||||
Console.WriteLine(title);
|
Console.Write($"- {title}...");
|
||||||
_writer.WriteLine(title + new string('=', Console.BufferWidth - title.Length));
|
_writer.WriteLine(title + new string('=', Console.BufferWidth - title.Length));
|
||||||
var totalTime = TimeSpan.Zero;
|
var totalTime = TimeSpan.Zero;
|
||||||
var stopWatch = new Stopwatch();
|
var stopWatch = new Stopwatch();
|
||||||
@ -43,21 +43,68 @@ namespace HeliosPlus.Reporting
|
|||||||
|
|
||||||
stopWatch.Stop();
|
stopWatch.Stop();
|
||||||
totalTime += stopWatch.Elapsed;
|
totalTime += stopWatch.Elapsed;
|
||||||
Console.Write(@"-- Elapsed: {0}", totalTime);
|
Console.WriteLine(@"(Took {0} to complete)", totalTime);
|
||||||
_writer.WriteLine(@"-- Total Elapsed: {0}", totalTime);
|
_writer.WriteLine(@"-- Total Elapsed: {0}", totalTime);
|
||||||
Console.WriteLine();
|
|
||||||
_writer.WriteLine();
|
_writer.WriteLine();
|
||||||
|
_writer.WriteLine(new string('#', Console.BufferWidth));
|
||||||
|
_writer.WriteLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void IngestFile(string fileName, string title)
|
||||||
|
{
|
||||||
|
|
||||||
|
Console.Write($"- {title}...");
|
||||||
|
_writer.WriteLine(new string('=', Console.BufferWidth));
|
||||||
|
_writer.WriteLine(title + new string('=', Console.BufferWidth - title.Length));
|
||||||
|
_writer.WriteLine(new string('=', Console.BufferWidth));
|
||||||
|
var totalTime = TimeSpan.Zero;
|
||||||
|
var stopWatch = new Stopwatch();
|
||||||
|
|
||||||
|
if (File.Exists(fileName))
|
||||||
|
{
|
||||||
|
stopWatch.Start();
|
||||||
|
|
||||||
|
StreamReader reader = new StreamReader(fileName);
|
||||||
|
string fileContents = reader.ReadToEnd();
|
||||||
|
_writer.WriteLine(fileContents);
|
||||||
|
|
||||||
|
stopWatch.Stop();
|
||||||
|
totalTime += stopWatch.Elapsed;
|
||||||
|
Console.WriteLine(@"(Took {0} to complete)", totalTime);
|
||||||
|
_writer.WriteLine(@"-- Total Elapsed: {0}", totalTime);
|
||||||
|
_writer.WriteLine();
|
||||||
|
_writer.WriteLine(new string('#', Console.BufferWidth));
|
||||||
|
_writer.WriteLine();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Main(string[] args)
|
private static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("HeliosPlus LogReporter");
|
||||||
|
Console.WriteLine("======================");
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("This program will interrogate your HeliosPlus configuration settings, the Windows Display ");
|
||||||
|
Console.WriteLine("Subsystem and any NVIDIA Display Drivers to record what they can detect and report. This");
|
||||||
|
Console.WriteLine("recorded information is then stored in a log file. If you report a problem then you may be");
|
||||||
|
Console.WriteLine("asked to send us the log file generated by this program in order for us to help you.");
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("Starting the interrogation...");
|
||||||
|
Console.WriteLine();
|
||||||
|
string date = DateTime.Now.ToString("yyyyMMdd.HHmmss");
|
||||||
_writer = new StreamWriter(new FileStream(
|
_writer = new StreamWriter(new FileStream(
|
||||||
string.Format("HeliosPlus.Reporting.{0}.log", Process.GetCurrentProcess().Id),
|
string.Format("HeliosPlus.Reporting.{0}.log", date),
|
||||||
FileMode.CreateNew));
|
FileMode.CreateNew));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Dump(DisplayAdapter.GetDisplayAdapters(), "WindowsDisplayAPI.DisplayAdapter.GetDisplayAdapters()");
|
IngestFile(Path.Combine(AppDataPath, "Settings_1.0.json"), "Storing HeliosPlus Settings JSON File");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -66,7 +113,35 @@ namespace HeliosPlus.Reporting
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Dump(Display.GetDisplays(), "WindowsDisplayAPI.Display.GetDisplays()", new[]
|
IngestFile(Path.Combine(AppDataPath, "Profiles", "DisplayProfiles_1.0.json"), "Storing HeliosPlus Display Profiles JSON File");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
WriteException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IngestFile(Path.Combine(AppDataPath, "Shortcuts", "Shortcuts_1.0.json"), "Storing HeliosPlus Shortcuts JSON File");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
WriteException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DumpObject(DisplayAdapter.GetDisplayAdapters(), "Storing a list of Display Adapters currently in this computer");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
WriteException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DumpObject(Display.GetDisplays(), "Storing a list of possible settings for Displays currently connected to this computer", new[]
|
||||||
{
|
{
|
||||||
new Tuple<Func<Display, object>, string>(display => display.GetPossibleSettings(),
|
new Tuple<Func<Display, object>, string>(display => display.GetPossibleSettings(),
|
||||||
"GetPossibleSettings()")
|
"GetPossibleSettings()")
|
||||||
@ -79,8 +154,8 @@ namespace HeliosPlus.Reporting
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Dump(UnAttachedDisplay.GetUnAttachedDisplays(),
|
DumpObject(UnAttachedDisplay.GetUnAttachedDisplays(),
|
||||||
"WindowsDisplayAPI.UnAttachedDisplay.GetUnAttachedDisplays()");
|
"Storing a list of Displays not currently in use, but currently connected to this computer");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -89,8 +164,8 @@ namespace HeliosPlus.Reporting
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Dump(PathDisplayAdapter.GetAdapters(),
|
DumpObject(PathDisplayAdapter.GetAdapters(),
|
||||||
"WindowsDisplayAPI.DisplayConfig.PathDisplayAdapter.GetAdapters()",
|
"Storing a list of Displays Targets for all Display Adapters currently in this computer",
|
||||||
new[]
|
new[]
|
||||||
{
|
{
|
||||||
new Tuple<Func<PathDisplayAdapter, object>, string>(adapter => adapter.ToDisplayAdapter(),
|
new Tuple<Func<PathDisplayAdapter, object>, string>(adapter => adapter.ToDisplayAdapter(),
|
||||||
@ -104,8 +179,8 @@ namespace HeliosPlus.Reporting
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Dump(PathDisplaySource.GetDisplaySources(),
|
DumpObject(PathDisplaySource.GetDisplaySources(),
|
||||||
"WindowsDisplayAPI.DisplayConfig.PathDisplaySource.GetDisplaySources()", new[]
|
"Storing a list of Display Sources for Displays currently connected to this computer", new[]
|
||||||
{
|
{
|
||||||
new Tuple<Func<PathDisplaySource, object>, string>(source => source.ToDisplayDevices(),
|
new Tuple<Func<PathDisplaySource, object>, string>(source => source.ToDisplayDevices(),
|
||||||
"ToDisplayDevices()")
|
"ToDisplayDevices()")
|
||||||
@ -118,8 +193,8 @@ namespace HeliosPlus.Reporting
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Dump(PathDisplayTarget.GetDisplayTargets(),
|
DumpObject(PathDisplayTarget.GetDisplayTargets(),
|
||||||
"WindowsDisplayAPI.DisplayConfig.PathDisplayTarget.GetDisplayTargets()", new[]
|
"Storing a list of Displays Targets for Displays currently connected to this computer", new[]
|
||||||
{
|
{
|
||||||
new Tuple<Func<PathDisplayTarget, object>, string>(target => target.ToDisplayDevice(),
|
new Tuple<Func<PathDisplayTarget, object>, string>(target => target.ToDisplayDevice(),
|
||||||
"ToDisplayDevice()")
|
"ToDisplayDevice()")
|
||||||
@ -134,7 +209,7 @@ namespace HeliosPlus.Reporting
|
|||||||
{
|
{
|
||||||
if (PathInfo.IsSupported)
|
if (PathInfo.IsSupported)
|
||||||
{
|
{
|
||||||
Dump(PathInfo.GetActivePaths(), "WindowsDisplayAPI.DisplayConfig.PathInfo.GetActivePaths()", null,
|
DumpObject(PathInfo.GetActivePaths(), "Storing a list of Active Displays currently connected to this computer", null,
|
||||||
2);
|
2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,7 +220,7 @@ namespace HeliosPlus.Reporting
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Dump(LogicalGPU.GetLogicalGPUs(), "NvAPIWrapper.GPU.LogicalGPU.GetLogicalGPUs()", null, 1);
|
DumpObject(LogicalGPU.GetLogicalGPUs(), "Storing a list of logical NVIDIA GPUs formed by NVIDIA GPUs currently in this computer (e.g. SLI)", null, 1);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -154,7 +229,7 @@ namespace HeliosPlus.Reporting
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Dump(PhysicalGPU.GetPhysicalGPUs(), "NvAPIWrapper.GPU.PhysicalGPU.GetPhysicalGPUs()");
|
DumpObject(PhysicalGPU.GetPhysicalGPUs(), "Storing a list of physical NVIDIA GPUs currently in this computer");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -163,7 +238,7 @@ namespace HeliosPlus.Reporting
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Dump(NvAPIWrapper.Display.Display.GetDisplays(), "NvAPIWrapper.Display.Display.GetDisplays()", new[]
|
DumpObject(NvAPIWrapper.Display.Display.GetDisplays(), "Storing a list of Displays currently connected to this computer through a NVIDIA GPU", new[]
|
||||||
{
|
{
|
||||||
new Tuple<Func<NvAPIWrapper.Display.Display, object>, string>(
|
new Tuple<Func<NvAPIWrapper.Display.Display, object>, string>(
|
||||||
display => display.GetSupportedViews(),
|
display => display.GetSupportedViews(),
|
||||||
@ -177,8 +252,8 @@ namespace HeliosPlus.Reporting
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Dump(NvAPIWrapper.Display.UnAttachedDisplay.GetUnAttachedDisplays(),
|
DumpObject(NvAPIWrapper.Display.UnAttachedDisplay.GetUnAttachedDisplays(),
|
||||||
"NvAPIWrapper.Display.UnAttachedDisplay.GetUnAttachedDisplays()");
|
"Storing a list of Displays currently connected to this computer through a NVIDIA GPU but not active");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -187,8 +262,8 @@ namespace HeliosPlus.Reporting
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Dump(NvAPIWrapper.Display.PathInfo.GetDisplaysConfig(),
|
DumpObject(NvAPIWrapper.Display.PathInfo.GetDisplaysConfig(),
|
||||||
"NvAPIWrapper.Display.PathInfo.GetDisplaysConfig()",
|
"Storing a list of configuration of Displays currently connected to this computer through a NVIDIA GPU",
|
||||||
null, 3);
|
null, 3);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -198,17 +273,7 @@ namespace HeliosPlus.Reporting
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Dump(GridTopology.GetGridTopologies(), "NvAPIWrapper.Mosaic.GridTopology.GetGridTopologies()", null, 3);
|
DumpObject(GridTopology.GetGridTopologies(), "Storing a list of configured NZIVIDA Surround/Mosaic settings involving multiple Displays via a NVIDIA GPU", null, 3);
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
WriteException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Dump(ProfileRepository.AllProfiles, "HeliosPlus.Shared.ProfileRepository.AllProfiles", null, 99);
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -219,12 +284,15 @@ namespace HeliosPlus.Reporting
|
|||||||
_writer.Close();
|
_writer.Close();
|
||||||
_writer.Dispose();
|
_writer.Dispose();
|
||||||
|
|
||||||
|
Console.WriteLine(new string('=', Console.BufferWidth));
|
||||||
|
Console.WriteLine();
|
||||||
Console.WriteLine(@"Done, press enter to exit.");
|
Console.WriteLine(@"Done, press enter to exit.");
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void WriteException(Exception ex)
|
private static void WriteException(Exception ex)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("{0} - Error: {1}", ex.GetType().Name, ex.Message);
|
||||||
_writer.WriteLine("{0} - Error: {1}", ex.GetType().Name, ex.Message);
|
_writer.WriteLine("{0} - Error: {1}", ex.GetType().Name, ex.Message);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user