Commit 73363f32 LN

日志修改

1 个父辈 150c5755
......@@ -265,7 +265,7 @@ namespace OnlineStore.ACPackingStore
}
private void btnClearLog_Click(object sender, EventArgs e)
{
logBox.Clear();
LogUtil.ClearLog();
}
private void debug_enable_checkBox_CheckedChanged(object sender, EventArgs e)
......
......@@ -25,59 +25,35 @@ namespace OnlineStore.Common
public static bool debug_opened = false;
public static void info(ILog log,string msg )
public static void info(ILog log, string msg)
{
if (log == null)
{
return;
}
log.Info( " - " + msg);
if (logBox == null)
{
return;
}
log.Info(" - " + msg);
AddToBox(msg, Color.Black);
//clear();
}
public static void info(ILog log,string msg, Color color)
{
log.Info( " - " + msg);
if (logBox == null)
public static void info(ILog log, string msg, Color color)
{
return;
}
log.Info(" - " + msg);
AddToBox(msg, color);
}
public static void debug(ILog log, string msg, Color color)
{
log.Debug( " - " + msg);
log.Debug(" - " + msg);
if (debug_opened)
{
if (logBox == null)
{
return;
}
AddToBox(msg, color);
}
}
public static void debug(ILog log, string msg)
{
log.Debug( " - " + msg);
log.Debug(" - " + msg);
if (debug_opened)
{
if (logBox == null)
{
return;
}
AddToBox(msg, Color.Gray);
}
}
private static List<string> lasErrorLogList = new List<string>();
private static int errCount = 5;
public static void error( string errorMsg,int type,int spanSeconds=10)
public static void error(string errorMsg, int type, int spanSeconds = 10)
{
if (lastErrorLogTime.ContainsKey(type))
{
......@@ -101,21 +77,9 @@ namespace OnlineStore.Common
}
public static void error(ILog log, string errorMsg)
{
//if (!lasErrorLogList.Contains(errorMsg))
{
log.Error( " - " + errorMsg);
if (logBox == null)
{
return;
}
log.Error(" - " + errorMsg);
AddToBox(errorMsg, Color.Red);
}
//lasErrorLogList.Add(errorMsg);
//if (lasErrorLogList.Count > errCount)
//{
// lasErrorLogList.RemoveAt(0);
//}
}
private static void AddToBox(string msg, Color color)
{
try
......@@ -127,49 +91,59 @@ namespace OnlineStore.Common
LOGGER.Error("出错:" + ex.StackTrace);
}
}
private static int count = 0;
private static List<string> logList = new List<string>();
private static void ShowLogPro(string msg, Color color)
{
try
{
//clear();
if (count > showCount)
if (logList.Count > 0)
{
logList.RemoveAt(0);
}
if (logList.Count >= showCount)
{
count = 0;
logBox.Clear();
logList.RemoveAt(logList.Count - 1);
}
//logBox.SelectionColor = color;
System.DateTime now = System.DateTime.Now;
logBox.AppendText(now.ToLongTimeString() + " " + msg + Environment.NewLine);
count++;
logList.Insert(0, now.ToLongTimeString() + " " + msg + Environment.NewLine);
logList.Insert(0, Environment.NewLine);
string text = "";
foreach (string str in logList)
{
text += str;
}
catch (Exception ex)
if (logBox == null)
{
LOGGER.Error("出错:" + ex.ToString());
return;
}
logBox.Text = text;
}
public static void debug(string msg)
catch (Exception ex)
{
debug(LOGGER, msg);
LOGGER.Error("出错:" + ex.ToString());
}
public static void error(string errorMsg)
{
error( LOGGER,errorMsg);
}
public static void ClearLog()
{
if (logBox != null)
{
logList.Clear();
logBox.Text = "";
count = 0;
}
}
public static void debug(string msg)
{
debug(LOGGER, msg);
}
public static void error(string errorMsg)
{
error(LOGGER, errorMsg);
}
public static void info(string msg)
{
info(LOGGER,msg );
info(LOGGER, msg);
}
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!