namespace com.hitrust.trustpay.client
|
|
{
|
|
using System;
|
|
using System.IO;
|
|
using System.Text;
|
|
|
|
public class LogWriter
|
|
{
|
|
internal StringBuilder iLogBuffer = new StringBuilder();
|
|
|
|
public virtual void closeWriter(Stream aLogFile)
|
|
{
|
|
try
|
|
{
|
|
if (aLogFile != null)
|
|
{
|
|
StreamWriter tLogFile = new StreamWriter(aLogFile, Encoding.GetEncoding("gb2312")) {
|
|
AutoFlush = true
|
|
};
|
|
tLogFile.Write(this.iLogBuffer.ToString());
|
|
tLogFile.Close();
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
|
|
public virtual void log(string aLogString)
|
|
{
|
|
try
|
|
{
|
|
aLogString = aLogString.Replace("\r", "");
|
|
aLogString = aLogString.Replace("\n", "\n ");
|
|
this.iLogBuffer.Append(aLogString);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
|
|
public virtual void logNewLine(string aLogString)
|
|
{
|
|
string tLogTime = new HiCalendar().toString("%Y/%m/%d-%H:%M:%S ");
|
|
try
|
|
{
|
|
this.iLogBuffer.Append("\n" + tLogTime);
|
|
aLogString = aLogString.Replace("\r", "");
|
|
aLogString = aLogString.Replace("\n", "\n ");
|
|
this.iLogBuffer.Append(aLogString);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|