You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
775 B

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());
}
}
}