diff --git a/BuildTime.txt b/BuildTime.txt index cd01455..0303d0c 100644 --- a/BuildTime.txt +++ b/BuildTime.txt @@ -1 +1 @@ -2026-03-15 15:59:37 \ No newline at end of file +2026-03-17 20:36:41 \ No newline at end of file diff --git a/GitCommit.txt b/GitCommit.txt index 55f76c4..aa7a9ed 100644 --- a/GitCommit.txt +++ b/GitCommit.txt @@ -1 +1 @@ -ffc4db8 \ No newline at end of file +e891672 \ No newline at end of file diff --git a/Logger/LogEntry.cs b/Logger/LogEntry.cs index 3a761a2..dbcf505 100644 --- a/Logger/LogEntry.cs +++ b/Logger/LogEntry.cs @@ -45,11 +45,25 @@ namespace CMLeonOS.Logger public override string ToString() { - string levelStr = GetLevelString(Level); - return "[" + levelStr + "] [" + Source + "] " + Message; + return $"[{GetLevelString(Level)}] [{Source}] {Message}"; } - private string GetLevelString(LogLevel level) + public string ToStringLevelStr() + { + return GetLevelString(Level); + } + + public string ToStringSource() + { + return Source; + } + + public string ToStringMessage() + { + return Message; + } + + public string GetLevelString(LogLevel level) { switch (level) { diff --git a/Logger/Logger.cs b/Logger/Logger.cs index ffe9f84..943d063 100644 --- a/Logger/Logger.cs +++ b/Logger/Logger.cs @@ -15,6 +15,8 @@ // along with this program. If not, see . using System; +using System.Security.Cryptography; +using XSharp.Assembler.x86.SSE; namespace CMLeonOS.Logger { @@ -100,8 +102,11 @@ namespace CMLeonOS.Logger private void WriteToConsole(LogEntry entry) { if (Settings.SettingsManager.LoggerEnabled) { - ConsoleColor originalColor = Console.ForegroundColor; + ConsoleColor originalBackgroundColor = Console.BackgroundColor; + ConsoleColor originalForegroundColor = Console.ForegroundColor; + // 日志等级 + Console.Write("[ "); switch (entry.Level) { case LogLevel.Debug: @@ -121,8 +126,44 @@ namespace CMLeonOS.Logger break; } - Console.WriteLine(entry.ToString()); - Console.ForegroundColor = originalColor; + // 我的审美就是依托 + // // 日志等级 + // Console.ForegroundColor = ConsoleColor.White; + // Console.Write(entry.ToStringLevelStr()); + + // // 空格 + // // Console.BackgroundColor = originalBackgroundColor; + // // Console.Write(" "); + + // // 日志来源 + // Console.BackgroundColor = ConsoleColor.Gray; + // Console.ForegroundColor = ConsoleColor.White; + // Console.Write(entry.ToStringSource()); + + // // 日志内容 + // Console.BackgroundColor = originalBackgroundColor; + // Console.ForegroundColor = ConsoleColor.White; + // // 空格 + // Console.Write(" "); + // Console.Write(entry.ToStringMessage()); + // // 换行 + // Console.WriteLine(); + + Console.Write(entry.ToStringLevelStr()); + Console.ForegroundColor = originalForegroundColor; + Console.Write(" ] "); + + // 日志来源 + Console.Write($"( {entry.Source} ) "); + + // 日志内容 + Console.Write(entry.ToStringMessage()); + + // 换行 + Console.WriteLine(); + + Console.ForegroundColor = originalForegroundColor; + Console.BackgroundColor = originalBackgroundColor; } } }