mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 11:37:01 +00:00
日志系统
This commit is contained in:
45
Logger/LogEntry.cs
Normal file
45
Logger/LogEntry.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
|
||||
namespace CMLeonOS.Logger
|
||||
{
|
||||
public class LogEntry
|
||||
{
|
||||
public DateTime Timestamp;
|
||||
public LogLevel Level;
|
||||
public string Source;
|
||||
public string Message;
|
||||
|
||||
public LogEntry(LogLevel level, string source, string message)
|
||||
{
|
||||
Timestamp = DateTime.Now;
|
||||
Level = level;
|
||||
Source = source;
|
||||
Message = message;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string levelStr = GetLevelString(Level);
|
||||
return "[" + levelStr + "] [" + Source + "] " + Message;
|
||||
}
|
||||
|
||||
private string GetLevelString(LogLevel level)
|
||||
{
|
||||
switch (level)
|
||||
{
|
||||
case LogLevel.Debug:
|
||||
return "DEBUG";
|
||||
case LogLevel.Info:
|
||||
return "INFO";
|
||||
case LogLevel.Warning:
|
||||
return "WARN";
|
||||
case LogLevel.Error:
|
||||
return "ERROR";
|
||||
case LogLevel.Success:
|
||||
return "SUCCESS";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user