class LoggerClass
{
}
public class LoggerEventArgs : EventArgs
{
public string Message { get ; private set ; }
public int Priority { get ; private set ; }
public LoggerEventArgs( int priority, string msg)
{
Priority = priority;
Message = msg;
}
}
public static struct LogerEventName
{
public static readonly string OnError = " OnError " ;
public static readonly string OnFail = " OnFail " ;
public static readonly string OnWaring = " OnWaring " ;
}
public sealed class Logger
{
private static Dictionary< string , EventHandler<LoggerEventArgs>> Handers = new Dictionary< string , EventHandler<LoggerEventArgs>>();
public static void AddLoger( string system,EventHandler<LoggerEventArgs> ev)
{
if (Handers.ContainsKey(system))
{
Handers[system] += ev;
}
else
{
Handers.Add(system,ev);
}
}
public static void RemoveLogger( string system,EventHandler<LoggerEventArgs> ev)
{
if (Handers.ContainsKey(system))
{
Handers[system] -= ev;
}
}
public static void AddMsg( string sytem, int priority, string msg)
{
if ( string .IsNullOrEmpty(sytem) || !Handers.ContainsKey(sytem))
return ;
LoggerEventArgs args = new LoggerEventArgs(priority,msg);
EventHandler<LoggerEventArgs> eventthander = null ;
Handers.TryGetValue(sytem, out eventthander);
if (eventthander != null )
eventthander( null , args);
}
}