mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 15:30:27 +00:00
38 lines
959 B
C#
38 lines
959 B
C#
|
|
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);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|