Skip to content

Commit

Permalink
Service logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Jun 27, 2024
1 parent ff9b7da commit b5e59b7
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion platforms/core/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"componentRefs": ["ServiceEntry"]
},
"webviewInstallMode": {
"type": "embedBootstrapper"
"type": "skip"
}
}
},
Expand Down
5 changes: 3 additions & 2 deletions platforms/windows/lib/Analytics.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text;
using Serilog;
using System.Text;
using System.Text.Json;

namespace lib {
Expand Down Expand Up @@ -29,7 +30,7 @@ public static async Task SendEvent(Settings settings) {
var responseContent = await response.Content.ReadAsStringAsync();
}
catch (Exception ex) {
Console.WriteLine($"An error occurred: {ex.Message}");
Log.Error("Failed to send analytics");
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions platforms/windows/lib/HardwareInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using LibreHardwareMonitor.Hardware;
using System.Diagnostics;
using Serilog;
using System.Net.NetworkInformation;
using WindowsDisplayAPI;

Expand Down Expand Up @@ -78,6 +78,8 @@ public void GetInfo() {
API.System.Network.Interfaces.Add(temp);
}
}

Log.Information("HW firstRun");
}

for (int i = 0; i < computer.Hardware.Count; i++) {
Expand Down Expand Up @@ -303,7 +305,7 @@ public void GetInfo() {
API.GPU.MaxLoad = GPULoad.MaxLoad;
}
catch (Exception) {
Debug.WriteLine("Error in GPULoad");
Log.Error("Error in GPULoad");
}
});
}
Expand Down Expand Up @@ -609,7 +611,7 @@ public void GetInfo() {
API.System.OS.Name = Commands.GetOSInfo();
}
catch (Exception) {
Debug.WriteLine("Failed to get GPU and OS name");
Log.Error("Failed to get GPU and OS name");
}

// RAM modules
Expand Down
1 change: 1 addition & 0 deletions platforms/windows/lib/lib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="8.0.0" />
<PackageReference Include="WindowsDisplayAPI" Version="1.3.0.13" />
<PackageReference Include="Sentry" Version="4.2.1" />
<PackageReference Include="Serilog" Version="4.0.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion platforms/windows/service/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static void Main(string[] args) {

Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.WriteTo.File("./service.log")
.WriteTo.File("./cores-service.log")
.CreateLogger();

AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Expand Down
2 changes: 1 addition & 1 deletion platforms/windows/service/WindowsBackgroundService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) {
Log.Information("Starting Cores service");
HardwareInfo.GetInfo();
HTTPServer.Start(HardwareInfo);
WSServer.Start(HardwareInfo)
WSServer.Start(HardwareInfo);

// Send analytics
_ = Task.Run(async () => {
Expand Down

0 comments on commit b5e59b7

Please sign in to comment.