Skip to content

Commit

Permalink
imp - brk|doc - Used Aptivestigate to better repor...
Browse files Browse the repository at this point in the history
...t debug

---

We've managed to integrate Aptivestigate into Nitrocid KS so that the
debug writer can use it, causing us to make breaking changes that removed
two settings entries.

---

Type: imp
Breaking: True
Doc Required: True
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Jan 7, 2025
1 parent 763b1e1 commit 11c03e1
Show file tree
Hide file tree
Showing 19 changed files with 134 additions and 188 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
changes!
-->
<NitrocidModAPIVersionMajor>3.0.25</NitrocidModAPIVersionMajor>
<NitrocidModAPIVersionChangeset>452</NitrocidModAPIVersionChangeset>
<NitrocidModAPIVersionChangeset>453</NitrocidModAPIVersionChangeset>

<!-- The above two properties are to be installed to the file version -->
<NitrocidModAPIVersion>$(NitrocidModAPIVersionMajor).$(NitrocidModAPIVersionChangeset)</NitrocidModAPIVersion>
Expand Down
4 changes: 2 additions & 2 deletions private/Nitrocid.Tests/InitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public static void ReadyEverything(TestContext tc)
Making.MakeDirectory(PathToTestSlotFolder, false);

// Enable debugging
string debugPath = Environment.CurrentDirectory + "/UnitTestDebug.log";
DebugWriter.DebugPath = debugPath;
KernelEntry.DebugMode = true;
string debugPath = Environment.CurrentDirectory + "/UnitTestDebug.log";
DebugWriter.InitializeDebug(debugPath);

// Load necessary addons for testing
AddonTools.ProcessAddons(ModLoadPriority.Important);
Expand Down
2 changes: 1 addition & 1 deletion public/Nitrocid.Templates/templates/KSMod/ModName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class ModName : IMod
public string Name { get; set; } = "My Mod";
public string Version { get; set; } = "1.0.0";

public Version MinimumSupportedApiVersion => new(3, 0, 25, 452);
public Version MinimumSupportedApiVersion => new(3, 0, 25, 453);

public ReadOnlyDictionary<string, Delegate> PubliclyAvailableFunctions => null;

Expand Down
17 changes: 11 additions & 6 deletions public/Nitrocid/Arguments/CommandLineArguments/Reset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using Terminaux.Writer.ConsoleWriters;
using Nitrocid.Files.Operations.Querying;
using Nitrocid.Kernel.Power;
using Nitrocid.Kernel.Debugging;

namespace Nitrocid.Arguments.CommandLineArguments
{
Expand All @@ -53,12 +54,6 @@ public override void Execute(ArgumentParameters parameters)
foreach (string recent in recents)
File.Delete(recent);
break;
case KernelPathType.Debugging:
TargetPath = TargetPath[..TargetPath.LastIndexOf(".log")] + "*.log";
string[] debugs = Listing.GetFilesystemEntries(TargetPath);
foreach (string debug in debugs)
File.Delete(debug);
break;
case KernelPathType.Journaling:
TargetPath = TargetPath[..TargetPath.LastIndexOf(".json")] + "*.json";
string[] journals = Listing.GetFilesystemEntries(TargetPath);
Expand Down Expand Up @@ -94,6 +89,16 @@ public override void Execute(ArgumentParameters parameters)
}
}

// Wipe debug logs
try
{
DebugWriter.RemoveDebugLogs();
}
catch (Exception ex)
{
TextWriters.Write(Translate.DoTranslation("Can't wipe debug files") + $": {ex.Message}", true, KernelColorType.Error);

Check warning on line 99 in public/Nitrocid/Arguments/CommandLineArguments/Reset.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

This string, "Can't wipe debug files", is unlocalized

Check warning on line 99 in public/Nitrocid/Arguments/CommandLineArguments/Reset.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

This string, "Can't wipe debug files", is unlocalized

Check warning on line 99 in public/Nitrocid/Arguments/CommandLineArguments/Reset.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

This string, "Can't wipe debug files", is unlocalized

Check warning on line 99 in public/Nitrocid/Arguments/CommandLineArguments/Reset.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

This string, "Can't wipe debug files", is unlocalized

Check warning on line 99 in public/Nitrocid/Arguments/CommandLineArguments/Reset.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

This string, "Can't wipe debug files", is unlocalized

Check warning on line 99 in public/Nitrocid/Arguments/CommandLineArguments/Reset.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

This string, "Can't wipe debug files", is unlocalized
}

// Inform user that the wipe was not complete if there are files.
string[] files = Listing.GetFilesystemEntries(PathsManagement.AppDataPath);
if (files.Length > 0)
Expand Down
8 changes: 4 additions & 4 deletions public/Nitrocid/Drivers/DebugLogger/BaseDebugLoggerDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public abstract class BaseDebugLoggerDriver : IDebugLoggerDriver
public virtual bool DriverInternal => false;

/// <inheritdoc/>
public virtual void Write(string text) =>
DebugWriter.DebugStreamWriter?.Write(text);
public virtual void Write(string text, DebugLevel level) =>
DebugWriter.DeterministicDebug(text, level, null);

/// <inheritdoc/>
public virtual void Write(string text, params object[] vars) =>
DebugWriter.DebugStreamWriter?.Write(text, vars);
public virtual void Write(string text, DebugLevel level, params object[] vars) =>
DebugWriter.DeterministicDebug(text, level, vars);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//

using Nitrocid.Kernel.Debugging;
using Terminaux.Writer.ConsoleWriters;

namespace Nitrocid.Drivers.DebugLogger.Bases
Expand All @@ -30,11 +31,11 @@ internal class ConsoleDebugLogger : BaseDebugLoggerDriver, IDebugLoggerDriver
public override bool DriverInternal => true;

/// <inheritdoc/>
public override void Write(string text) =>
public override void Write(string text, DebugLevel level) =>
TextWriterColor.Write(text, false);

/// <inheritdoc/>
public override void Write(string text, params object[] vars) =>
public override void Write(string text, DebugLevel level, params object[] vars) =>
TextWriterColor.Write(text, false, vars);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//

using Nitrocid.Kernel.Debugging;
using Terminal = System.Console;

namespace Nitrocid.Drivers.DebugLogger.Bases
Expand All @@ -30,11 +31,11 @@ internal class UnitTestDebugLogger : BaseDebugLoggerDriver, IDebugLoggerDriver
public override bool DriverInternal => true;

/// <inheritdoc/>
public override void Write(string text) =>
public override void Write(string text, DebugLevel level) =>
Terminal.Write(text);

/// <inheritdoc/>
public override void Write(string text, params object[] vars) =>
public override void Write(string text, DebugLevel level, params object[] vars) =>
Terminal.Write(text, vars);
}
}
8 changes: 6 additions & 2 deletions public/Nitrocid/Drivers/DebugLogger/IDebugLoggerDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//

using Nitrocid.Kernel.Debugging;

namespace Nitrocid.Drivers.DebugLogger
{
/// <summary>
Expand All @@ -28,13 +30,15 @@ public interface IDebugLoggerDriver : IDriver
/// Outputs the text into the debugger file, and sets the time stamp.
/// </summary>
/// <param name="text">A sentence that will be written to the the debugger file. Supports {0}, {1}, ...</param>
void Write(string text);
/// <param name="level">Debug level</param>
void Write(string text, DebugLevel level);

/// <summary>
/// Outputs the text into the debugger file, and sets the time stamp.
/// </summary>
/// <param name="text">A sentence that will be written to the the debugger file. Supports {0}, {1}, ...</param>
/// <param name="level">Debug level</param>
/// <param name="vars">Variables to format the message before it's written.</param>
void Write(string text, params object[] vars);
void Write(string text, DebugLevel level, params object[] vars);
}
}
4 changes: 0 additions & 4 deletions public/Nitrocid/Files/Paths/KernelPathType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ public enum KernelPathType
/// </summary>
Configuration,
/// <summary>
/// Kernel debug log file.
/// </summary>
Debugging,
/// <summary>
/// Aliases file.
/// </summary>
Aliases,
Expand Down
7 changes: 0 additions & 7 deletions public/Nitrocid/Files/Paths/PathsManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public static class PathsManagement
{ $"{KernelPathType.Configuration}", (() => ConfigurationPath, true) },
{ $"{KernelPathType.CustomLanguages}", (() => CustomLanguagesPath, true) },
{ $"{KernelPathType.DebugDevices}", (() => DebugDevicesPath, true) },
{ $"{KernelPathType.Debugging}", (() => DebuggingPath, true) },
{ $"{KernelPathType.Events}", (() => EventsPath, true) },
{ $"{KernelPathType.SpeedDial}", (() => SpeedDialPath, true) },
{ $"{KernelPathType.MAL}", (() => MALPath, true) },
Expand Down Expand Up @@ -156,12 +155,6 @@ public static string RetroKSDownloadPath
public static string ConfigurationPath =>
FilesystemTools.NeutralizePath(AppDataPath + "/KernelMainConfig.json");

/// <summary>
/// Debugging path
/// </summary>
public static string DebuggingPath =>
FilesystemTools.NeutralizePath(AppDataPath + "/kernelDbg.log");

/// <summary>
/// Aliases path
/// </summary>
Expand Down
12 changes: 0 additions & 12 deletions public/Nitrocid/Kernel/Configuration/Instances/KernelMainConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,6 @@ public double BlindnessSeverity
/// </summary>
public bool AllowUntrustedMods { get; set; }
/// <summary>
/// Enables debug quota check
/// </summary>
public bool DebugQuotaCheck { get; set; }
/// <summary>
/// How many lines to print to the debug buffer before reaching the quota limit?
/// </summary>
public int DebugQuotaLines { get; set; } = 10000;
/// <summary>
/// Whether to use the operating system time zone or to use the kernel-wide time zone
/// </summary>
public bool UseSystemTimeZone
Expand All @@ -216,10 +208,6 @@ public string KernelWideTimeZone
/// Shows an informational box for the program license for fifteen seconds after each login
/// </summary>
public bool ShowLicenseInfoBox { get; set; } = true;
/// <summary>
/// Uses the legacy log style
/// </summary>
public bool DebugLegacyLogStyle { get; set; } = true;
#endregion

#region Colors
Expand Down
Loading

0 comments on commit 11c03e1

Please sign in to comment.