using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace Utils
|
|
{
|
|
public static class LogUtil
|
|
{
|
|
|
|
public static void LogLine(string message, string level = "info", bool console = true, bool logFile = true)
|
|
{
|
|
var leveInfo = string.Format("{0:yyyy/M/d h:m:s} [{1}] ", DateTime.Now, level);
|
|
|
|
if (console) {
|
|
Console.Write(leveInfo);
|
|
Console.WriteLine(message);
|
|
}
|
|
|
|
if (logFile) {
|
|
Trace.Write(leveInfo);
|
|
Trace.WriteLine(message);
|
|
}
|
|
|
|
}
|
|
|
|
public static void LogError(string messagage)
|
|
{
|
|
LogLine(messagage, level: "error");
|
|
}
|
|
|
|
public static void LogError(Exception ex)
|
|
{
|
|
LogError(ex.ToString());
|
|
}
|
|
}
|
|
}
|