3 Commits

Author SHA1 Message Date
89d750fbe6 Add some logging and handle update error
All checks were successful
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 54s
2026-01-27 20:30:48 -05:00
2e14ff032b Adjust logging and add debugger option
All checks were successful
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 1m12s
2026-01-27 19:59:51 -05:00
13ae4c74bc Add separate logs
All checks were successful
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 52s
2026-01-27 19:23:11 -05:00
8 changed files with 94 additions and 37 deletions

View File

@@ -31,6 +31,6 @@ jobs:
run: | run: |
export PATH="$PATH:/root/.dotnet/tools" export PATH="$PATH:/root/.dotnet/tools"
dotnet tool install -g vpk dotnet tool install -g vpk
#vpk [win] download gitea --channel win-x64 --repoUrl https://gitea.kaczorzoo.net/ckaczor/HardwareMonitorStatusWindow vpk [win] download gitea --channel win-x64 --repoUrl https://gitea.kaczorzoo.net/ckaczor/HardwareMonitorStatusWindow
vpk [win] pack --channel win-x64 -u HardwareMonitorStatusWindow -v ${{ steps.version.outputs.version }} -p publish --packTitle "Hardware Monitor Status Window" --shortcuts StartMenuRoot --framework net10.0-x64-desktop vpk [win] pack --channel win-x64 -u HardwareMonitorStatusWindow -v ${{ steps.version.outputs.version }} -p publish --packTitle "Hardware Monitor Status Window" --shortcuts StartMenuRoot --framework net10.0-x64-desktop
vpk [win] upload gitea --channel win-x64 --repoUrl https://gitea.kaczorzoo.net/ckaczor/HardwareMonitorStatusWindow --publish --releaseName "${{ steps.version.outputs.version }}" --token ${{ secrets.VPK_TOKEN }} vpk [win] upload gitea --channel win-x64 --repoUrl https://gitea.kaczorzoo.net/ckaczor/HardwareMonitorStatusWindow --publish --releaseName "${{ steps.version.outputs.version }}" --token ${{ secrets.VPK_TOKEN }}

View File

@@ -1,3 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=dragdrop/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=dragdrop/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Kaczor/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> <s:Boolean x:Key="/Default/UserDictionary/Words/=Kaczor/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Velopack/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@@ -1,4 +1,5 @@
using LibreHardwareMonitor.Hardware; using LibreHardwareMonitor.Hardware;
using Serilog;
namespace HardwareMonitorStatusWindow.Service; namespace HardwareMonitorStatusWindow.Service;
@@ -12,6 +13,8 @@ public class HardwareMonitorService : IHardwareMonitorService
static HardwareMonitorService() static HardwareMonitorService()
{ {
Log.Information("Creating computer");
Computer = new Computer Computer = new Computer
{ {
IsCpuEnabled = true, IsCpuEnabled = true,
@@ -25,6 +28,8 @@ public class HardwareMonitorService : IHardwareMonitorService
IsPsuEnabled = true IsPsuEnabled = true
}; };
Log.Information("Opening computer");
Computer.Open(); Computer.Open();
HardwareUpdateVisitor = new HardwareUpdateVisitor(); HardwareUpdateVisitor = new HardwareUpdateVisitor();
@@ -32,8 +37,12 @@ public class HardwareMonitorService : IHardwareMonitorService
public IEnumerable<Hardware> GetHardware() public IEnumerable<Hardware> GetHardware()
{ {
Log.Information("Updating computer");
Computer.Accept(HardwareUpdateVisitor); Computer.Accept(HardwareUpdateVisitor);
Log.Information("Creating hardware entries");
var hardwareEntries = Computer.Hardware.Select(Hardware.Create); var hardwareEntries = Computer.Hardware.Select(Hardware.Create);
return hardwareEntries; return hardwareEntries;

View File

@@ -12,13 +12,13 @@ internal class Program
{ {
private static async Task Main(string[] args) private static async Task Main(string[] args)
{ {
Log.Logger = new LoggerConfiguration().WriteTo.File("log.txt").CreateLogger(); Log.Logger = new LoggerConfiguration().WriteTo.File("HardwareMonitorService.log").CreateLogger();
Log.Logger.Information("Start"); Log.Information("Start");
if (args.Contains("--install", StringComparer.InvariantCultureIgnoreCase)) if (args.Contains("--install", StringComparer.InvariantCultureIgnoreCase))
{ {
Log.Logger.Information("Starting install..."); Log.Information("Starting install...");
try try
{ {
@@ -48,14 +48,14 @@ internal class Program
} }
catch (Exception exception) catch (Exception exception)
{ {
Log.Logger.Error(exception, "Install"); Log.Error(exception, "");
} }
Log.Logger.Information("Install complete"); Log.Information("Install complete");
} }
else if (args.Contains("--uninstall", StringComparer.InvariantCultureIgnoreCase)) else if (args.Contains("--uninstall", StringComparer.InvariantCultureIgnoreCase))
{ {
Log.Logger.Information("Starting uninstall..."); Log.Information("Starting uninstall...");
try try
{ {
@@ -69,43 +69,51 @@ internal class Program
} }
catch (Exception exception) catch (Exception exception)
{ {
Log.Logger.Error(exception, "Uninstall"); Log.Error(exception, "");
} }
Log.Logger.Information("Uninstall complete"); Log.Information("Uninstall complete");
} }
else else
{ {
Log.Logger.Information("Starting"); Log.Information("Starting");
try try
{ {
while (true) while (true)
{ {
Log.Information("Creating PipeSecurity");
var pipeSecurity = new PipeSecurity(); var pipeSecurity = new PipeSecurity();
pipeSecurity.AddAccessRule(new PipeAccessRule(new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null), PipeAccessRights.ReadWrite, AccessControlType.Allow)); pipeSecurity.AddAccessRule(new PipeAccessRule(new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null), PipeAccessRights.ReadWrite, AccessControlType.Allow));
Log.Information("Creating NamedPipe");
var pipeWithSecurity = NamedPipeServerStreamAcl.Create(HardwareMonitorService.PipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, 0, 0, pipeSecurity); var pipeWithSecurity = NamedPipeServerStreamAcl.Create(HardwareMonitorService.PipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, 0, 0, pipeSecurity);
Log.Information("Creating PipeServer");
var pipeServer = new PipeServer<IHardwareMonitorService>(new HardwarePipeSerializer(), pipeWithSecurity, () => new HardwareMonitorService()); var pipeServer = new PipeServer<IHardwareMonitorService>(new HardwarePipeSerializer(), pipeWithSecurity, () => new HardwareMonitorService());
//var pipeServer = new PipeServer<IHardwareMonitorService>(
// new HardwarePipeSerializer(), Log.Information("Waiting for connection");
// HardwareMonitorService.PipeName,
// () => new HardwareMonitorService());
await pipeServer.WaitForConnectionAsync().ConfigureAwait(false); await pipeServer.WaitForConnectionAsync().ConfigureAwait(false);
Log.Information("Waiting for remote pipe to close");
await pipeServer.WaitForRemotePipeCloseAsync().ConfigureAwait(false); await pipeServer.WaitForRemotePipeCloseAsync().ConfigureAwait(false);
Log.Information("Disposing pipe server");
pipeServer.Dispose(); pipeServer.Dispose();
} }
} }
catch (Exception exception) catch (Exception exception)
{ {
Log.Logger.Error(exception, ""); Log.Error(exception, "");
} }
} }
Log.Logger.Information("Closing"); Log.Information("Closing");
} }
} }

View File

@@ -1,5 +1,6 @@
using System; using Serilog;
using Serilog; using System;
using System.Diagnostics;
using Velopack; using Velopack;
namespace HardwareMonitorStatusWindow.StatusWindow; namespace HardwareMonitorStatusWindow.StatusWindow;
@@ -9,18 +10,19 @@ internal class Program
[STAThread] [STAThread]
public static void Main(string[] args) public static void Main(string[] args)
{ {
Log.Logger = new LoggerConfiguration().WriteTo.File("log.txt").CreateLogger(); if (args.Contains("--debug"))
Debugger.Launch();
Log.Logger.Information("Start"); Log.Logger = new LoggerConfiguration().WriteTo.File("HardwareMonitorStatusWindow.log").CreateLogger();
// var loggerFactory = new LoggerFactory().AddSerilog(Log.Logger); Log.Information("Start");
VelopackApp.Build().Run(); // loggerFactory.CreateLogger("Install") VelopackApp.Build().SetLogger(new SerilogVelopackLogger()).Run();
var app = new App(); var app = new App();
app.InitializeComponent(); app.InitializeComponent();
app.Run(); app.Run();
Log.Logger.Information("End"); Log.Information("End");
} }
} }

View File

@@ -0,0 +1,18 @@
using System;
using Velopack.Logging;
namespace HardwareMonitorStatusWindow.StatusWindow;
internal class SerilogVelopackLogger : IVelopackLogger
{
public void Log(VelopackLogLevel logLevel, string? message, Exception? exception)
{
if (exception != null)
{
Serilog.Log.Error(exception, "");
return;
}
Serilog.Log.Information("[{time}] [{logLevel}] {message}", DateTime.Now.ToShortTimeString(), logLevel, message);
}
}

View File

@@ -30,11 +30,11 @@ internal static class UpdateCheck
if (MessageBox.Show(updateCheckMessage, updateCheckTitle, MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes) if (MessageBox.Show(updateCheckMessage, updateCheckTitle, MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
return; return;
Log.Logger.Information("Downloading update"); Log.Information("Downloading update");
await UpdateManager.DownloadUpdatesAsync(newVersion); await UpdateManager.DownloadUpdatesAsync(newVersion);
Log.Logger.Information("Installing update"); Log.Information("Installing update");
UpdateManager.ApplyUpdatesAndRestart(newVersion); UpdateManager.ApplyUpdatesAndRestart(newVersion);
} }

View File

@@ -30,18 +30,26 @@ internal class WindowSource : IWindowSource, IDisposable
{ {
using var taskService = new TaskService(); using var taskService = new TaskService();
Log.Information("Checking for task name: {name}", HardwareMonitorService.ScheduledTaskName);
var existingTask = taskService.FindTask(HardwareMonitorService.ScheduledTaskName); var existingTask = taskService.FindTask(HardwareMonitorService.ScheduledTaskName);
Log.Information("Task: {existingTask}", existingTask);
if (existingTask == null) if (existingTask == null)
{ {
var assembly = Assembly.GetExecutingAssembly(); var assembly = Assembly.GetExecutingAssembly();
var path = Path.GetDirectoryName(assembly.Location); var path = Path.GetDirectoryName(assembly.Location);
Log.Information("Service path: {path}", path);
if (path != null) if (path != null)
{ {
var fileName = Path.Combine(path, "HardwareMonitorService.exe"); var fileName = Path.Combine(path, "HardwareMonitorService.exe");
Log.Information("Full service path: {fileName}", fileName);
var startInfo = new ProcessStartInfo var startInfo = new ProcessStartInfo
{ {
FileName = fileName, FileName = fileName,
@@ -50,13 +58,16 @@ internal class WindowSource : IWindowSource, IDisposable
Verb = "runas" Verb = "runas"
}; };
Log.Information("Starting process");
Process.Start(startInfo); Process.Start(startInfo);
} }
} }
} }
catch (Exception) catch (Exception exception)
{ {
// Ignored // Ignored
Log.Error(exception, "");
} }
_floatingStatusWindow = new FloatingStatusWindow(this); _floatingStatusWindow = new FloatingStatusWindow(this);
@@ -73,36 +84,44 @@ internal class WindowSource : IWindowSource, IDisposable
{ {
try try
{ {
Log.Information("IsInstalled: {isInstalled}", UpdateCheck.IsInstalled);
if (!UpdateCheck.IsInstalled) if (!UpdateCheck.IsInstalled)
return false; return false;
Log.Information("CheckVersionAtStartup: {checkVersionAtStartup}", Settings.Default.CheckVersionAtStartup);
if (!Settings.Default.CheckVersionAtStartup) if (!Settings.Default.CheckVersionAtStartup)
return false; return false;
Log.Logger.Information("Checking for update");
await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(Resources.CheckingForUpdate)); await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(Resources.CheckingForUpdate));
Log.Information("Checking for updates");
var newVersion = await UpdateCheck.UpdateManager.CheckForUpdatesAsync(); var newVersion = await UpdateCheck.UpdateManager.CheckForUpdatesAsync();
Log.Information("New version: {version}", newVersion);
if (newVersion == null) if (newVersion == null)
return false; return false;
Log.Logger.Information("Downloading update");
await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(Resources.DownloadingUpdate)); await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(Resources.DownloadingUpdate));
Log.Information("Downloading update");
await UpdateCheck.UpdateManager.DownloadUpdatesAsync(newVersion); await UpdateCheck.UpdateManager.DownloadUpdatesAsync(newVersion);
Log.Logger.Information("Installing update");
await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(Resources.InstallingUpdate)); await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(Resources.InstallingUpdate));
Log.Information("Installing update");
UpdateCheck.UpdateManager.ApplyUpdatesAndRestart(newVersion); UpdateCheck.UpdateManager.ApplyUpdatesAndRestart(newVersion);
} }
catch (Exception e) catch (Exception e)
{ {
Log.Logger.Error(e, nameof(UpdateApp)); Log.Error(e, nameof(UpdateApp));
return false;
} }
return true; return true;
@@ -110,16 +129,16 @@ internal class WindowSource : IWindowSource, IDisposable
private async Task Start(bool hasUpdate) private async Task Start(bool hasUpdate)
{ {
Log.Logger.Information("Start: hasUpdate={hasUpdate}", hasUpdate); Log.Information("Start: hasUpdate={hasUpdate}", hasUpdate);
if (hasUpdate) if (hasUpdate)
return; return;
Log.Logger.Information("Load"); Log.Information("Load");
await Load(); await Load();
Log.Logger.Information("Starting timer"); Log.Information("Starting timer");
_timer.Elapsed += HandleTimerElapsed; _timer.Elapsed += HandleTimerElapsed;
_timer.AutoReset = false; _timer.AutoReset = false;