diff --git a/src/SharpEmu.CLI/packages.lock.json b/src/SharpEmu.CLI/packages.lock.json index a06b7f9..95a7cc2 100644 --- a/src/SharpEmu.CLI/packages.lock.json +++ b/src/SharpEmu.CLI/packages.lock.json @@ -216,7 +216,10 @@ } }, "sharpemu.hle": { - "type": "Project" + "type": "Project", + "dependencies": { + "SharpEmu.Logging": "[1.0.0, )" + } }, "sharpemu.libs": { "type": "Project", diff --git a/src/SharpEmu.Core/packages.lock.json b/src/SharpEmu.Core/packages.lock.json index c3f7ecb..42a3d8e 100644 --- a/src/SharpEmu.Core/packages.lock.json +++ b/src/SharpEmu.Core/packages.lock.json @@ -65,7 +65,10 @@ "contentHash": "Iy22JopynbOJ32vA0lBhFEzGi65GQJBuJHYBYRBpydrDpNoTiHnjIXfA65Gu+8qsOr/ZEoIF8r9aHCgAXuO6DA==" }, "sharpemu.hle": { - "type": "Project" + "type": "Project", + "dependencies": { + "SharpEmu.Logging": "[1.0.0, )" + } }, "sharpemu.libs": { "type": "Project", diff --git a/src/SharpEmu.HLE/Aerolib/Aerolib.cs b/src/SharpEmu.HLE/Aerolib/Aerolib.cs index 5013972..19949e4 100644 --- a/src/SharpEmu.HLE/Aerolib/Aerolib.cs +++ b/src/SharpEmu.HLE/Aerolib/Aerolib.cs @@ -3,11 +3,13 @@ using System.Buffers.Binary; using System.Linq; +using SharpEmu.Logging; namespace SharpEmu.HLE; public sealed class Aerolib : ISymbolCatalog { + private static readonly SharpEmuLogger Log = SharpEmuLog.For("Aerolib"); private static readonly Lazy _instance = new(() => new Aerolib()); private static readonly Aerolib EmptyCatalog = new Aerolib(empty: true); @@ -108,14 +110,14 @@ public sealed class Aerolib : ISymbolCatalog if (resourceName == null) { - Console.Error.WriteLine("[AEROLIB] Embedded resource 'aerolib.bin' not found"); + Log.Error("Embedded resource 'aerolib.bin' not found"); return; } using var stream = assembly.GetManifestResourceStream(resourceName); if (stream == null) { - Console.Error.WriteLine("[AEROLIB] Failed to open embedded resource stream"); + Log.Error("Failed to open embedded resource stream"); return; } @@ -145,11 +147,11 @@ public sealed class Aerolib : ISymbolCatalog _byExportName[name] = symbol; } - Console.Error.WriteLine($"[AEROLIB] Loaded {_byNid.Count} NID entries from binary resource"); + Log.Info($"Loaded {_byNid.Count} NID entries from binary resource"); } catch (Exception ex) { - Console.Error.WriteLine($"[AEROLIB] Failed to load embedded aerolib.bin: {ex.Message}"); + Log.Error($"Failed to load embedded aerolib.bin: {ex.Message}", ex); } } diff --git a/src/SharpEmu.HLE/ModuleManager.cs b/src/SharpEmu.HLE/ModuleManager.cs index aaf34b6..4484278 100644 --- a/src/SharpEmu.HLE/ModuleManager.cs +++ b/src/SharpEmu.HLE/ModuleManager.cs @@ -3,11 +3,14 @@ using System.Collections.Concurrent; using System.Reflection; +using SharpEmu.Logging; namespace SharpEmu.HLE; public sealed class ModuleManager : IModuleManager { + private static readonly SharpEmuLogger Log = SharpEmuLog.For("HLE"); + private readonly ConcurrentDictionary _dispatchTable = new(StringComparer.Ordinal); private readonly ConcurrentDictionary _exportTable = new(StringComparer.Ordinal); private readonly ConcurrentDictionary _exportNameTable = new(StringComparer.Ordinal); @@ -47,7 +50,7 @@ public sealed class ModuleManager : IModuleManager var handler = CreateHandler(type, method, instances); if (!_dispatchTable.TryAdd(exportInfo.Value.Nid, handler)) { - Console.Error.WriteLine($"[HLE] Duplicate NID '{exportInfo.Value.Nid}' ({exportInfo.Value.ExportName}) — already registered, skipping."); + Log.Warning($"Duplicate NID '{exportInfo.Value.Nid}' ({exportInfo.Value.ExportName}) — already registered, skipping."); continue; } @@ -106,7 +109,7 @@ public sealed class ModuleManager : IModuleManager if (!_dispatchTable.TryGetValue(nid, out var function) || !_exportTable.TryGetValue(nid, out var export)) { - Console.Error.WriteLine($"[HLE] NID '{nid}' not found in dispatch table."); + Log.Warning($"NID '{nid}' not found in dispatch table."); context[CpuRegister.Rax] = unchecked((ulong)(int)OrbisGen2Result.ORBIS_GEN2_ERROR_NOT_FOUND); result = OrbisGen2Result.ORBIS_GEN2_ERROR_NOT_FOUND; return false; @@ -114,7 +117,7 @@ public sealed class ModuleManager : IModuleManager if ((export.Target & context.TargetGeneration) == 0) { - Console.Error.WriteLine($"[HLE] NID '{nid}' ({export.Name}) found but not implemented for generation {context.TargetGeneration} (targets: {export.Target})."); + Log.Warning($"NID '{nid}' ({export.Name}) found but not implemented for generation {context.TargetGeneration} (targets: {export.Target})."); context[CpuRegister.Rax] = unchecked((ulong)(int)OrbisGen2Result.ORBIS_GEN2_ERROR_NOT_IMPLEMENTED); result = OrbisGen2Result.ORBIS_GEN2_ERROR_NOT_IMPLEMENTED; return false; diff --git a/src/SharpEmu.HLE/SharpEmu.HLE.csproj b/src/SharpEmu.HLE/SharpEmu.HLE.csproj index 96cfce3..6b026db 100644 --- a/src/SharpEmu.HLE/SharpEmu.HLE.csproj +++ b/src/SharpEmu.HLE/SharpEmu.HLE.csproj @@ -12,6 +12,10 @@ SPDX-License-Identifier: GPL-2.0-or-later $(NoWarn);1591 + + + + diff --git a/src/SharpEmu.HLE/packages.lock.json b/src/SharpEmu.HLE/packages.lock.json index 6afd678..b0f4ada 100644 --- a/src/SharpEmu.HLE/packages.lock.json +++ b/src/SharpEmu.HLE/packages.lock.json @@ -1,6 +1,10 @@ { "version": 2, "dependencies": { - "net10.0": {} + "net10.0": { + "sharpemu.logging": { + "type": "Project" + } + } } } \ No newline at end of file diff --git a/src/SharpEmu.Libs/packages.lock.json b/src/SharpEmu.Libs/packages.lock.json index 49c33ed..4a4f120 100644 --- a/src/SharpEmu.Libs/packages.lock.json +++ b/src/SharpEmu.Libs/packages.lock.json @@ -98,6 +98,12 @@ "contentHash": "Iy22JopynbOJ32vA0lBhFEzGi65GQJBuJHYBYRBpydrDpNoTiHnjIXfA65Gu+8qsOr/ZEoIF8r9aHCgAXuO6DA==" }, "sharpemu.hle": { + "type": "Project", + "dependencies": { + "SharpEmu.Logging": "[1.0.0, )" + } + }, + "sharpemu.logging": { "type": "Project" } }