42 lines
946 B
C#
42 lines
946 B
C#
using System;
|
|
using System.Diagnostics;
|
|
|
|
namespace Gallery.Util
|
|
{
|
|
public static class Log
|
|
{
|
|
public static ILog Logger { get; set; } = new DefaultLogger();
|
|
|
|
public static void Print(string message)
|
|
{
|
|
Logger?.Print(message);
|
|
}
|
|
|
|
public static void Error(string category, string message)
|
|
{
|
|
Logger?.Error(category, message);
|
|
}
|
|
}
|
|
|
|
public class DefaultLogger : ILog
|
|
{
|
|
public void Print(string message)
|
|
{
|
|
#if DEBUG
|
|
Debug.WriteLine("[{0:HH:mm:ss.fff}] - {1}", DateTime.Now, message);
|
|
#endif
|
|
}
|
|
|
|
public void Error(string category, string message)
|
|
{
|
|
Debug.Fail(string.Format("[{0:HH:mm:ss.fff}] - {1} - {2}", DateTime.Now, category, message));
|
|
}
|
|
}
|
|
|
|
public interface ILog
|
|
{
|
|
void Print(string message);
|
|
void Error(string category, string message);
|
|
}
|
|
}
|