Going to bed but i wanna show off my cool debugging system
This commit is contained in:
@@ -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.
|
||||
37
Awperative/Kernel/Communication/Debug/Core.cs
Normal file
37
Awperative/Kernel/Communication/Debug/Core.cs
Normal 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");
|
||||
}
|
||||
}
|
||||
68
Awperative/Kernel/Communication/Debug/Writer.cs
Normal file
68
Awperative/Kernel/Communication/Debug/Writer.cs
Normal 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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user