mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-04-21 19:24:00 +00:00
更换日志样式
This commit is contained in:
@@ -1 +1 @@
|
|||||||
2026-03-15 15:59:37
|
2026-03-17 20:36:41
|
||||||
@@ -1 +1 @@
|
|||||||
ffc4db8
|
e891672
|
||||||
@@ -45,11 +45,25 @@ namespace CMLeonOS.Logger
|
|||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
string levelStr = GetLevelString(Level);
|
return $"[{GetLevelString(Level)}] [{Source}] {Message}";
|
||||||
return "[" + levelStr + "] [" + 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)
|
switch (level)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using XSharp.Assembler.x86.SSE;
|
||||||
|
|
||||||
namespace CMLeonOS.Logger
|
namespace CMLeonOS.Logger
|
||||||
{
|
{
|
||||||
@@ -100,8 +102,11 @@ namespace CMLeonOS.Logger
|
|||||||
private void WriteToConsole(LogEntry entry)
|
private void WriteToConsole(LogEntry entry)
|
||||||
{
|
{
|
||||||
if (Settings.SettingsManager.LoggerEnabled) {
|
if (Settings.SettingsManager.LoggerEnabled) {
|
||||||
ConsoleColor originalColor = Console.ForegroundColor;
|
ConsoleColor originalBackgroundColor = Console.BackgroundColor;
|
||||||
|
ConsoleColor originalForegroundColor = Console.ForegroundColor;
|
||||||
|
|
||||||
|
// 日志等级
|
||||||
|
Console.Write("[ ");
|
||||||
switch (entry.Level)
|
switch (entry.Level)
|
||||||
{
|
{
|
||||||
case LogLevel.Debug:
|
case LogLevel.Debug:
|
||||||
@@ -121,8 +126,44 @@ namespace CMLeonOS.Logger
|
|||||||
break;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user