mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 15:30:27 +00:00
GUI桌面环境
This commit is contained in:
37
Logger/Log.cs
Normal file
37
Logger/Log.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CMLeonOS.Logger
|
||||
{
|
||||
public static class Log
|
||||
{
|
||||
private static List<LogEntry> logs = new List<LogEntry>();
|
||||
private static List<Action<LogEntry>> logEmittedReceivers = new List<Action<LogEntry>>();
|
||||
|
||||
public static List<LogEntry> Logs
|
||||
{
|
||||
get { return logs; }
|
||||
}
|
||||
|
||||
public static List<Action<LogEntry>> LogEmittedReceivers
|
||||
{
|
||||
get { return logEmittedReceivers; }
|
||||
}
|
||||
|
||||
public static void AddReceiver(Action<LogEntry> receiver)
|
||||
{
|
||||
logEmittedReceivers.Add(receiver);
|
||||
}
|
||||
|
||||
public static void Emit(LogLevel level, string source, string message)
|
||||
{
|
||||
var entry = new LogEntry(level, source, message);
|
||||
logs.Add(entry);
|
||||
|
||||
foreach (var receiver in logEmittedReceivers)
|
||||
{
|
||||
receiver(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,16 @@ namespace CMLeonOS.Logger
|
||||
public LogLevel Level;
|
||||
public string Source;
|
||||
public string Message;
|
||||
|
||||
public LogLevel Priority
|
||||
{
|
||||
get { return Level; }
|
||||
}
|
||||
|
||||
public DateTime Date
|
||||
{
|
||||
get { return Timestamp; }
|
||||
}
|
||||
|
||||
public LogEntry(LogLevel level, string source, string message)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user