forked from cyq1162/cyqdata
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogAdapter.cs
27 lines (22 loc) · 1.57 KB
/
LogAdapter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System;
namespace CYQ.Data.Cache
{
internal class LogAdapter
{
public static LogAdapter GetLogger(Type type)
{
return new LogAdapter(type);
}
private string loggerName;
private LogAdapter(string name) { loggerName = name; }
private LogAdapter(Type type) { loggerName = type.FullName; }
public void Debug(string message) { Log.WriteLogToTxt(DateTime.Now + loggerName + " - " + message, LogType.Debug); }
public void Info(string message) { Log.WriteLogToTxt(DateTime.Now + loggerName + " - " + message, LogType.Info); }
public void Warn(string message) { Log.WriteLogToTxt(DateTime.Now + loggerName + " - " + message, LogType.Warn); }
public void Error(string message) { Log.WriteLogToTxt(DateTime.Now + loggerName + " - " + message, LogType.Error); }
public void Debug(string message, Exception e) { Log.WriteLogToTxt(DateTime.Now + loggerName + " - " + message + "\n" + e.Message + "\n" + e.StackTrace, LogType.Debug); }
public void Info(string message, Exception e) { Log.WriteLogToTxt(DateTime.Now + loggerName + " - " + message + "\n" + e.Message + "\n" + e.StackTrace, LogType.Info); }
public void Warn(string message, Exception e) { Log.WriteLogToTxt(DateTime.Now + loggerName + " - " + message + "\n" + e.Message + "\n" + e.StackTrace, LogType.Warn); }
public void Error(string message, Exception e) { Log.WriteLogToTxt(DateTime.Now + loggerName + " - " + message + "\n" + e.Message + "\n" + e.StackTrace, LogType.Error); }
}
}