Commit e9880b04 LN

错误日志重新定义

1 个父辈 6a892985
...@@ -323,7 +323,7 @@ namespace OnlineStore.Common ...@@ -323,7 +323,7 @@ namespace OnlineStore.Common
catch (Exception ex) catch (Exception ex)
{ {
isOk = false; isOk = false;
LogUtil.error( "SendCommand ERROR:" + ex.ToString(),1020); LogUtil.error( "SendCommand ERROR:" + ex.ToString(),108);
} }
finally finally
{ {
......
...@@ -61,22 +61,29 @@ namespace OnlineStore.Common ...@@ -61,22 +61,29 @@ namespace OnlineStore.Common
{ {
rfidLog.Debug(msg); rfidLog.Debug(msg);
} }
public static void error(string errorMsg, int type,int seconds=10) public static void error(string errorMsg, int type, int seconds = 10)
{ {
if (lastErrorLogTime.ContainsKey(type)) try
{ {
TimeSpan span = DateTime.Now - lastErrorLogTime[type]; if (lastErrorLogTime.ContainsKey(type))
if (span.TotalSeconds > seconds) {
TimeSpan span = DateTime.Now - lastErrorLogTime[type];
if (span.TotalSeconds > seconds)
{
lastErrorLogTime.Remove(type);
lastErrorLogTime.Add(type, DateTime.Now);
error(LOGGER, errorMsg);
}
}
else
{ {
lastErrorLogTime.Remove(type);
lastErrorLogTime.Add(type, DateTime.Now); lastErrorLogTime.Add(type, DateTime.Now);
error(LOGGER, errorMsg); error(LOGGER, errorMsg);
} }
} }
else catch (Exception ex)
{ {
lastErrorLogTime.Add(type, DateTime.Now); LOGGER.Error(" 打印日志【" + type + "-" + errorMsg + "】出错:" + ex.ToString());
error(LOGGER, errorMsg);
} }
} }
public static void error(ILog log, string errorMsg, Exception ex = null) public static void error(ILog log, string errorMsg, Exception ex = null)
......
...@@ -112,7 +112,7 @@ namespace OnlineStore.Common ...@@ -112,7 +112,7 @@ namespace OnlineStore.Common
} }
catch (Exception e) catch (Exception e)
{ {
LogUtil.error("POST ERROR:" + e.ToString(), 1001); LogUtil.error("POST ERROR:" + e.ToString(), 101);
} }
if (!result.Contains("null") && result.Length != 0) if (!result.Contains("null") && result.Length != 0)
{ {
...@@ -146,7 +146,7 @@ namespace OnlineStore.Common ...@@ -146,7 +146,7 @@ namespace OnlineStore.Common
} }
catch (Exception e) catch (Exception e)
{ {
LogUtil.error("HTTP GET ERROR:" + e.Message, 1002); LogUtil.error("HTTP GET ERROR:" + e.Message, 102);
} }
return ""; return "";
} }
......
...@@ -119,7 +119,7 @@ namespace OnlineStore.Common ...@@ -119,7 +119,7 @@ namespace OnlineStore.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error( "Connect to " + serverIP + ":" + serverPort + " fail!" + ex.ToString(), 1003); LogUtil.error( "Connect to " + serverIP + ":" + serverPort + " fail!" + ex.ToString(), 103);
//m_clientSocket = null; //m_clientSocket = null;
} }
} }
...@@ -233,7 +233,7 @@ namespace OnlineStore.Common ...@@ -233,7 +233,7 @@ namespace OnlineStore.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error( "socket received error:" + ex.ToString(), 1004); LogUtil.error( "socket received error:" + ex.ToString(), 104);
} }
} }
} }
......
...@@ -166,11 +166,11 @@ namespace OnlineStore.Common ...@@ -166,11 +166,11 @@ namespace OnlineStore.Common
} }
catch (SocketException e) catch (SocketException e)
{ {
LogUtil.error("客户端{" + client.AddStr + "]:" + e.ToString(), 1006); LogUtil.error("客户端{" + client.AddStr + "]:" + e.ToString(), 106);
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error("客户端{" + client.AddStr + "]:" + ex.ToString(), 1005); LogUtil.error("客户端{" + client.AddStr + "]:" + ex.ToString(), 105);
} }
} }
//private void ReceiveMessages(Client client) //private void ReceiveMessages(Client client)
......
...@@ -410,7 +410,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -410,7 +410,7 @@ namespace OnlineStore.DeviceLibrary
Alarm(LineAlarmType.AxisMoveError); Alarm(LineAlarmType.AxisMoveError);
CheckAlarmProcess(moveInfo, LineAlarmType.AxisMoveError); CheckAlarmProcess(moveInfo, LineAlarmType.AxisMoveError);
LogUtil.error(WarnMsg, DeviceID + 18); LogUtil.error(WarnMsg, DeviceID * 1000 + 14);
break; break;
} }
} }
...@@ -429,7 +429,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -429,7 +429,7 @@ namespace OnlineStore.DeviceLibrary
ConfigIO io = baseConfig.getWaitIO(wait.IoType); ConfigIO io = baseConfig.getWaitIO(wait.IoType);
WarnMsg = moveInfo.Name + "[" + moveInfo.MoveType + "][" + moveInfo.MoveStep + "] 等待" + NotOkMsg + " 超时 " + Math.Round(span.TotalSeconds, 1) + "秒"; WarnMsg = moveInfo.Name + "[" + moveInfo.MoveType + "][" + moveInfo.MoveStep + "] 等待" + NotOkMsg + " 超时 " + Math.Round(span.TotalSeconds, 1) + "秒";
LogUtil.error(MoveInfo.Name + WarnMsg, DeviceID + 13); LogUtil.error(MoveInfo.Name + WarnMsg, DeviceID * 1000 + 13);
if (NoAlarm()) if (NoAlarm())
{ {
Alarm(LineAlarmType.IoSingleTimeOut); Alarm(LineAlarmType.IoSingleTimeOut);
...@@ -527,7 +527,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -527,7 +527,7 @@ namespace OnlineStore.DeviceLibrary
{ {
second = 10; second = 10;
} }
LogUtil.error(WarnMsg, DeviceID + 15, second); LogUtil.error(WarnMsg, DeviceID * 1000 + 15, second);
Alarm(LineAlarmType.IoSingleTimeOut); Alarm(LineAlarmType.IoSingleTimeOut);
CheckAlarmProcess(moveInfo, LineAlarmType.IoSingleTimeOut); CheckAlarmProcess(moveInfo, LineAlarmType.IoSingleTimeOut);
} }
......
...@@ -441,7 +441,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -441,7 +441,7 @@ namespace OnlineStore.DeviceLibrary
else if (SecondMoveInfo.IsTimeOut(60)) else if (SecondMoveInfo.IsTimeOut(60))
{ {
WarnMsg = SecondMoveInfo.Name + "[" + SecondMoveInfo.MoveStep + "] 等待出库移栽超时 [" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒"; WarnMsg = SecondMoveInfo.Name + "[" + SecondMoveInfo.MoveStep + "] 等待出库移栽超时 [" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒";
LogUtil.error(WarnMsg, DeviceID + 11); LogUtil.error(WarnMsg, DeviceID * 1000 + 21);
Alarm(LineAlarmType.IoSingleTimeOut); Alarm(LineAlarmType.IoSingleTimeOut);
} }
} }
...@@ -892,7 +892,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -892,7 +892,7 @@ namespace OnlineStore.DeviceLibrary
else if (MoveInfo.IsTimeOut(180)) else if (MoveInfo.IsTimeOut(180))
{ {
WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.SLog + "]等待空托盘到达超时[" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒"; WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.SLog + "]等待空托盘到达超时[" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒";
LogUtil.error(WarnMsg, DeviceID + 12); LogUtil.error(WarnMsg, DeviceID * 1000 + 22);
Alarm(LineAlarmType.IoSingleTimeOut); Alarm(LineAlarmType.IoSingleTimeOut);
} }
//送出料架处理 //送出料架处理
...@@ -1323,19 +1323,19 @@ namespace OnlineStore.DeviceLibrary ...@@ -1323,19 +1323,19 @@ namespace OnlineStore.DeviceLibrary
//判断是否有料架,是否可以出库 //判断是否有料架,是否可以出库
if (IOValue(IO_Type.SL_Location_Check).Equals(IO_VALUE.LOW)) if (IOValue(IO_Type.SL_Location_Check).Equals(IO_VALUE.LOW))
{ {
LogUtil.error(Name + " 【" + info.ToStr() + "】需要出库,定位工位无料架,暂不处理", DeviceID + 16); LogUtil.error(Name + " 【" + info.ToStr() + "】需要出库,定位工位无料架,暂不处理", DeviceID * 1000 + 16);
return false; return false;
} }
else if (OutStoreHeight < 0) else if (OutStoreHeight < 0)
{ {
LogUtil.error(Name + " 【" + info.ToStr() + "】需要出库,料架未准备好,暂不处理", DeviceID + 17); LogUtil.error(Name + " 【" + info.ToStr() + "】需要出库,料架未准备好,暂不处理", DeviceID * 1000 + 17);
return false; return false;
} }
//如果已经开始送出料架,暂不处理 //如果已经开始送出料架,暂不处理
if (MoveInfo.MoveType.Equals(LineMoveType.OutStore)&& MoveInfo.MoveStep >= LineMoveStep.FO_30_BatchAxisToP2) if (MoveInfo.MoveType.Equals(LineMoveType.OutStore)&& MoveInfo.MoveStep >= LineMoveStep.FO_30_BatchAxisToP2)
{ {
LogUtil.error(Name + " 【" + info.ToStr() + "】需要出库,正在送出料架,暂不处理", DeviceID + 18); LogUtil.error(Name + " 【" + info.ToStr() + "】需要出库,正在送出料架,暂不处理", DeviceID * 1000 + 18);
return false; return false;
} }
......
...@@ -909,7 +909,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -909,7 +909,7 @@ namespace OnlineStore.DeviceLibrary
if (span.TotalSeconds > LineManager.Config.IOSingle_TimerOut * 2) if (span.TotalSeconds > LineManager.Config.IOSingle_TimerOut * 2)
{ {
SetWarnMsg(moveEquip.Name + "下降阻挡气缸超时,已等待" + FormUtil.GetSpanStr(span)); SetWarnMsg(moveEquip.Name + "下降阻挡气缸超时,已等待" + FormUtil.GetSpanStr(span));
LogUtil.error(moveEquip.Name + "下降阻挡气缸超时,已等待" + FormUtil.GetSpanStr(span), 112); LogUtil.error(moveEquip.Name + "下降阻挡气缸超时,已等待" + FormUtil.GetSpanStr(span), 902);
} }
else if (rwSpan.TotalSeconds > 5 && span.TotalSeconds > 6 && span.TotalSeconds < LineManager.Config.IOSingle_TimerOut * 2) else if (rwSpan.TotalSeconds > 5 && span.TotalSeconds > 6 && span.TotalSeconds < LineManager.Config.IOSingle_TimerOut * 2)
{ {
...@@ -970,7 +970,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -970,7 +970,7 @@ namespace OnlineStore.DeviceLibrary
else if (span.TotalSeconds > 120) else if (span.TotalSeconds > 120)
{ {
WarnMsg = Name + "[" + MoveInfo.MoveStep + "][" + msg + "]已等待[" + Math.Round(span.TotalSeconds, 1) + "]秒"; WarnMsg = Name + "[" + MoveInfo.MoveStep + "][" + msg + "]已等待[" + Math.Round(span.TotalSeconds, 1) + "]秒";
LogUtil.error(WarnMsg, 100); LogUtil.error(WarnMsg, 903);
Alarm(LineAlarmType.IoSingleTimeOut); Alarm(LineAlarmType.IoSingleTimeOut);
} }
} }
......
...@@ -107,7 +107,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -107,7 +107,7 @@ namespace OnlineStore.DeviceLibrary
ConfigIO io = baseConfig.getWaitIO(wait.IoType); ConfigIO io = baseConfig.getWaitIO(wait.IoType);
WarnMsg = Name + "[" + checkWaitInfo.MoveStep + "]等待" + NotOkMsg + " 超时"; WarnMsg = Name + "[" + checkWaitInfo.MoveStep + "]等待" + NotOkMsg + " 超时";
Alarm(LineAlarmType.IoSingleTimeOut); Alarm(LineAlarmType.IoSingleTimeOut);
LogUtil.error(MoveInfo.Name + WarnMsg, DeviceID + 13); LogUtil.error(MoveInfo.Name + WarnMsg, 901);
} }
//超过报警时长 //超过报警时长
else if (rwSpan.TotalSeconds > 5 && span.TotalSeconds > 6 && span.TotalSeconds < LineManager.Config.IOSingle_TimerOut * 2) else if (rwSpan.TotalSeconds > 5 && span.TotalSeconds > 6 && span.TotalSeconds < LineManager.Config.IOSingle_TimerOut * 2)
...@@ -182,7 +182,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -182,7 +182,7 @@ namespace OnlineStore.DeviceLibrary
else if (span.TotalSeconds > checkWaitInfo.TimeOutSeconds) else if (span.TotalSeconds > checkWaitInfo.TimeOutSeconds)
{ {
WarnMsg = checkWaitInfo.Name + "[" + checkWaitInfo.MoveStep + "][" + NotOkMsg + "]已等待[" + Math.Round(span.TotalSeconds, 1) + "]秒"; WarnMsg = checkWaitInfo.Name + "[" + checkWaitInfo.MoveStep + "][" + NotOkMsg + "]已等待[" + Math.Round(span.TotalSeconds, 1) + "]秒";
LogUtil.error(WarnMsg, 100); LogUtil.error(WarnMsg, 900);
Alarm(LineAlarmType.IoSingleTimeOut); Alarm(LineAlarmType.IoSingleTimeOut);
} }
} }
......
...@@ -204,7 +204,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -204,7 +204,7 @@ namespace OnlineStore.DeviceLibrary
else if (MoveInfo.IsTimeOut(180)) else if (MoveInfo.IsTimeOut(180))
{ {
WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.SLog + "]等待空托盘到达超时[" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒"; WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.SLog + "]等待空托盘到达超时[" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒";
LogUtil.error(WarnMsg, DeviceID + 12); LogUtil.error(WarnMsg, DeviceID * 1000 + 12);
Alarm(LineAlarmType.IoSingleTimeOut); Alarm(LineAlarmType.IoSingleTimeOut);
return false; return false;
} }
......
...@@ -61,7 +61,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -61,7 +61,7 @@ namespace OnlineStore.DeviceLibrary
{ {
if (LastTrayPosition <= 1) if (LastTrayPosition <= 1)
{ {
LogUtil.error(Name + " 启动送料【" + moveParam.ToStr() + "】 失败,入口有料" , Id + 32); LogUtil.error(Name + " 启动送料【" + moveParam.ToStr() + "】 失败,入口有料" , Id * 1000 + 32);
return false; return false;
} }
//MoveInfo.MoveParam = moveParam; //MoveInfo.MoveParam = moveParam;
...@@ -102,7 +102,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -102,7 +102,7 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
LogUtil.error(Name + " 启动送料【" + moveParam.ToStr() + "】 失败", Id + 31); LogUtil.error(Name + " 启动送料【" + moveParam.ToStr() + "】 失败", Id * 1000 + 31);
return false; return false;
} }
} }
...@@ -142,7 +142,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -142,7 +142,7 @@ namespace OnlineStore.DeviceLibrary
} }
else if (MoveInfo.IsTimeOut(180)) else if (MoveInfo.IsTimeOut(180))
{ {
LogUtil.error(Name + "等待入口无料超时" + FormUtil.GetSpanStr(MoveInfo.StepSpan()), Id + 33); LogUtil.error(Name + "等待入口无料超时" + FormUtil.GetSpanStr(MoveInfo.StepSpan()), Id * 1000 + 33);
} }
} }
......
...@@ -541,7 +541,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -541,7 +541,7 @@ namespace OnlineStore.DeviceLibrary
else if (MoveInfo.IsTimeOut()) else if (MoveInfo.IsTimeOut())
{ {
WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "]等待 皮带线可放料 " + "超时[" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒"; WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "]等待 皮带线可放料 " + "超时[" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒";
LogUtil.error(WarnMsg, DeviceID + 20); LogUtil.error(WarnMsg, DeviceID * 1000 + 20);
Alarm(LineAlarmType.IoSingleTimeOut); Alarm(LineAlarmType.IoSingleTimeOut);
} }
} }
......
...@@ -155,7 +155,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -155,7 +155,7 @@ namespace OnlineStore.DeviceLibrary
{ {
msg = " " + MoveInfo.SLog + MoveInfo.Name + axis.DisplayStr + ",目标位置[" + targetPosition + "]当前位置[" + outCount msg = " " + MoveInfo.SLog + MoveInfo.Name + axis.DisplayStr + ",目标位置[" + targetPosition + "]当前位置[" + outCount
+ "],误差过大,需要报警"; + "],误差过大,需要报警";
LogUtil.error(msg, 1034); LogUtil.error(msg, 600);
} }
} }
return false; return false;
......
...@@ -280,11 +280,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -280,11 +280,11 @@ namespace OnlineStore.DeviceLibrary
{ {
if (msg.StartsWith(Name)) if (msg.StartsWith(Name))
{ {
LogUtil.error(msg, 105); LogUtil.error(msg, 801);
} }
else else
{ {
LogUtil.error(Name + msg, 105); LogUtil.error(Name + msg, 801);
} }
} }
else else
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!