65 lines
1.1 KiB
C#
65 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace CPF.ReoGrid.Common
|
|
{
|
|
public class Logger
|
|
{
|
|
internal static Logger Instance
|
|
{
|
|
get
|
|
{
|
|
return Logger.instance;
|
|
}
|
|
}
|
|
|
|
private Logger()
|
|
{
|
|
this.writters.Add(new ConsoleLogger());
|
|
}
|
|
|
|
public static void RegisterWritter(ILogWritter writter)
|
|
{
|
|
Logger.instance.writters.Add(writter);
|
|
}
|
|
|
|
public static void Off()
|
|
{
|
|
Logger.instance.turnSwitch = false;
|
|
}
|
|
|
|
public static void On()
|
|
{
|
|
Logger.instance.turnSwitch = true;
|
|
}
|
|
|
|
public static void Log(string cat, string format, params object[] args)
|
|
{
|
|
Logger.Log(cat, string.Format(format, args));
|
|
}
|
|
|
|
public static void Log(string cat, string msg)
|
|
{
|
|
Logger.instance.WriteLog(cat, msg);
|
|
}
|
|
|
|
public void WriteLog(string cat, string msg)
|
|
{
|
|
bool flag = this.turnSwitch;
|
|
if (flag)
|
|
{
|
|
this.writters.ForEach(delegate(ILogWritter w)
|
|
{
|
|
w.Log(cat, msg);
|
|
});
|
|
}
|
|
}
|
|
|
|
private static readonly Logger instance = new Logger();
|
|
|
|
private List<ILogWritter> writters = new List<ILogWritter>();
|
|
|
|
private bool turnSwitch = true;
|
|
}
|
|
}
|