//using System.Linq;
using System;
using System.IO;
using System.Text;
namespace WayneCloud.PaymentProcessors.Alipay.FromSDK
{
///
/// LogHelper 的摘要说明
///
public class LogHelper
{
string logFile = "";
///
/// 不带参数的构造函数
///
public LogHelper()
{
}
///
/// 带参数的构造函数
///
///
public LogHelper(string logFile)
{
this.logFile = logFile;
if (!File.Exists(logFile))
{
FileStream fs = File.Create(logFile);
fs.Close();
}
}
///
/// 追加一条信息
///
///
public void Write(string text)
{
using (StreamWriter sw = new StreamWriter(logFile, true, Encoding.UTF8))
{
sw.Write(DateTime.Now.ToString("[yyyy-MM-dd HH:mm:ss] ") + text);
}
}
///
/// 追加一条信息
///
///
///
public void Write(string logFile, string text)
{
using (StreamWriter sw = new StreamWriter(logFile, true, Encoding.UTF8))
{
sw.Write(DateTime.Now.ToString("[yyyy-MM-dd HH:mm:ss] ") + text);
}
}
///
/// 追加一行信息
///
///
public void WriteLine(string text)
{
text += "\r\n";
using (StreamWriter sw = new StreamWriter(logFile, true, Encoding.UTF8))
{
sw.Write(DateTime.Now.ToString("[yyyy-MM-dd HH:mm:ss] ") + text);
}
}
///
/// 追加一行信息
///
///
///
public void WriteLine(string logFile, string text)
{
text += "\r\n";
using (StreamWriter sw = new StreamWriter(logFile, true, Encoding.UTF8))
{
sw.Write(DateTime.Now.ToString("[yyyy-MM-dd HH:mm:ss] ") + text);
}
}
}
}