using Kingdee.BOS.Log;
using System;
using System.IO;
namespace Gatedge.Enpower.BOS.PlugIn.Utils
{
internal class LogUtil
{
//private const string LogPath = "GzLog\\";
private const string LogPath = "C:\\Kingdee_Gatedge_Log\\";
public static void Log(string logName, string logInfo)
{
var log = logInfo + "\r\n--------------------------------------------------------\r\n";
var path = LogPath + logName;
var fileName = GetFileName();
var fullPath = path + fileName;
WriteLog(fullPath, log);
}
public static void Log(string[] logNames, string logInfo)
{
var log = logInfo + "\r\n--------------------------------------------------------\r\n";
var pathName = string.Join("\\", logNames);
var path = LogPath + pathName;
var fileName = GetFileName();
var fullPath = path + fileName;
WriteLog(fullPath, log);
}
private static string GetFileName()
{
var dateTime = DateTime.Now;
var fileName = "\\KD_Gatedge_" + dateTime.ToString("yyyy-MM-dd_HH-mm-ss") + ".log";
return "\\" + string.Empty;
//return fileName;
}
private static void WriteLog(string path, string logInfo)
{
if (!Directory.Exists(Path.GetDirectoryName(path)))
{
Directory.CreateDirectory(Path.GetDirectoryName(path));
}
FileStream fileStream = new FileStream(path, FileMode.OpenOrCreate);
StreamWriter streamWriter = new StreamWriter(fileStream);
fileStream.Position = fileStream.Length;
streamWriter.Write(logInfo);
streamWriter.Flush();
streamWriter.Close();
fileStream.Close();
Logger.Info(path, logInfo);
}
///
/// 删除早于该时间前的日志
///
///
private static void RemoveLog(DateTime dateTime)
{
}
}
}