mirror of
https://github.com/tonytins/s2pk.git
synced 2025-05-19 15:33:17 -04:00
Serilog integration
This commit is contained in:
parent
9af646b534
commit
d7e477c4dd
6 changed files with 24 additions and 10 deletions
|
@ -1,7 +1,7 @@
|
|||
[Desktop Entry]
|
||||
Name=s2pk
|
||||
Name=Sims 2 Package Manager
|
||||
Exec=s2pk
|
||||
Icon=s2pk
|
||||
Icon=logo.svg
|
||||
Type=Application
|
||||
Categories=Utility;
|
||||
Terminal=true
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
global using S2PK;
|
||||
global using Tomlyn;
|
||||
global using Serilog;
|
||||
global using Serilog.Sinks.Debug;
|
||||
global using Serilog.Sinks.Console;
|
||||
|
|
|
@ -28,14 +28,14 @@ public static class PackageManager
|
|||
|
||||
if (!dir.Exists)
|
||||
{
|
||||
Console.Error.WriteLine("Source directory does not exist.");
|
||||
Log.Error("Source directory does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
var packageFiles = dir.GetFiles($"*{PackageExtension}", SearchOption.AllDirectories);
|
||||
if (packageFiles.Length == 0)
|
||||
{
|
||||
Console.Error.WriteLine("No .package files found to pack.");
|
||||
Log.Error("No .package files found to pack.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ public static class PackageManager
|
|||
// Check if destination directory exists
|
||||
if (!Directory.Exists(destination))
|
||||
{
|
||||
Console.Error.WriteLine("Destination directory does not exist.");
|
||||
Log.Error("Destination directory does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -85,21 +85,21 @@ public static class PackageManager
|
|||
|
||||
if (!file.Exists)
|
||||
{
|
||||
Console.Error.WriteLine("Package file does not exist.");
|
||||
Log.Error("Package file does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!file.FullName.Contains(extension))
|
||||
{
|
||||
Console.Error.WriteLine("Package file is not a valid.");
|
||||
Log.Error("Package file is not a valid.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for extension mismatch
|
||||
if (file.FullName.Contains(S3pkExtension) && !ts3)
|
||||
{
|
||||
Console.Error.WriteLine("Package is for The Sims 3 but unpacking for The Sims 2.");
|
||||
Log.Error("Package is for The Sims 3 but unpacking for The Sims 2.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ public static class PackageManager
|
|||
// Sanitize path to prevent directory traversal
|
||||
if (!fullPath.StartsWith(dir.FullName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Console.Error.WriteLine($"Skipping unsafe path: {entry.FullName}");
|
||||
Log.Error($"Skipping unsafe path: {entry.FullName}");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,14 @@ using System.CommandLine;
|
|||
|
||||
var rootCommand = new RootCommand("The Sims 2 .s2pk Package Manager");
|
||||
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
#if DEBUG
|
||||
.WriteTo.Debug()
|
||||
#else
|
||||
.WriteTo.Console(theme: AnsiConsoleTheme.Code)
|
||||
#endif
|
||||
.CreateLogger();
|
||||
|
||||
var sims3option = new Option<bool>(
|
||||
aliases: ["--ts3"],
|
||||
description: "Switch to The Sims 3 mode.",
|
||||
|
|
|
@ -26,7 +26,7 @@ While The Sims 2 runs well on Linux through Wine, especially with Lutris setups,
|
|||
| ----- | ------------------------------------------- | ------ |
|
||||
| v0.1 | Core package manager | ✅ |
|
||||
| v0.2 | Config file with default paths | ✅ |
|
||||
| v0.3 | Sims 3 support with `s3pk` extention | 🔜 |
|
||||
| v0.3 | Sims 3 support with `s3pk` extension | 🔜 |
|
||||
| v0.x | Target .NET 10 | 🔜 |
|
||||
| v1.0 | Stable "Release" version with documentation | 🔜 |
|
||||
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Serilog" Version="4.2.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Debug" Version="3.0.0" />
|
||||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
|
||||
<PackageReference Include="Tomlyn" Version="0.19.0" />
|
||||
</ItemGroup>
|
||||
|
|
Loading…
Add table
Reference in a new issue