Going to bed but i wanna show off my cool debugging system

This commit is contained in:
2026-02-01 23:02:53 -05:00
parent 6370a70e77
commit 6032a04ad9
20 changed files with 303 additions and 47 deletions

View File

@@ -0,0 +1,5 @@
Awperative debugger writes errors to file while staying within runtime.
Searches for a file with any specifiable name in config. that must end in .awlf
stands for awperative logging format.

View File

@@ -0,0 +1,37 @@
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using Awperative.Kernel.Communication.Config;
namespace Awperative;
public static partial class Debugger
{
/// <summary>
/// True path of the log file Awperative dumps to.
/// </summary>
public static string LogFilePath { get; private set; }
/// <summary>
/// Sets up the Awperative debugger and finds the log file.
/// </summary>
internal static void Initiate() {
string directoryPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if(directoryPath == null) throw new Exception("Failed to get directory path!");
if(!Directory.GetFiles(directoryPath).Contains(Config.logFileName + ".awlf")) throw new Exception("Failed to find log file!");
LogFilePath = Path.Join(directoryPath, Config.logFileName + ".awlf");
}
}

View File

@@ -0,0 +1,68 @@
using System.Diagnostics;
using System.IO;
namespace Awperative;
public static partial class Debugger
{
/// <summary>
/// Writes the current message to the log file.
/// </summary>
/// <param name="__message"> Message to debug</param>
public static void DebugState(string __message) => DebugGeneric(__message, "STA");
/// <summary>
/// Writes the current message to the log file.
/// </summary>
/// <param name="__message"> Message to debug</param>
public static void DebugValue(string __message) => DebugGeneric(__message, "VAL");
/// <summary>
/// Writes the current message to the log file.
/// </summary>
/// <param name="__message"> Message to debug</param>
public static void DebugLog(string __message) => DebugGeneric(__message, "LOG");
/// <summary>
/// Writes the current message to the log file.
/// </summary>
/// <param name="__message"> Message to debug</param>
public static void DebugWarning(string __message) => DebugGeneric(__message, "WAR");
/// <summary>
/// Writes the current message to the log file.
/// </summary>
/// <param name="__message"> Message to debug</param>
public static void DebugError(string __message) => DebugGeneric(__message, "ERR");
/// <summary>
/// Writes the current message to the log file. With any given call sign.
/// </summary>
/// <param name="__message"> Message to debug</param>
/// <param name="__callSign"> Message identifier</param>
public static void DebugGeneric(string __message, string __callSign) {
File.AppendAllText(LogFilePath, "\n\n" + __callSign + "- \"" + __message + "\"\n STK-" + new StackTrace());
}
}