Commit 954d374f LN

log修改

1 个父辈 5df9c727
......@@ -409,7 +409,7 @@ namespace OnlineStore.AssemblyLine
}
private void btnClearLog_Click(object sender, EventArgs e)
{
logBox.Clear();
LogUtil.ClearLog();
}
private void debug_enable_checkBox_CheckedChanged(object sender, EventArgs e)
......
......@@ -13,64 +13,47 @@ namespace OnlineStore.Common
{
public static readonly ILog AIOLog = LogManager.GetLogger("AIOBOXLog");
private static LogUtil instance = new LogUtil();
public delegate void ShowLog(string msg, Color color);
public delegate void ShowLog(string msg, Color color);
public static readonly ILog LOGGER = LogManager.GetLogger("RollingLogFileAppender");
public static readonly ILog rfidLog = LogManager.GetLogger("RfidLog");
public static Dictionary<int, DateTime> lastErrorLogTime = new Dictionary<int, DateTime>();
public static System.Windows.Forms.RichTextBox logBox = null;
public static int showCount = 20;
public static int showCount = 15;
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;
}
AddToBox(msg, Color.Black);
log.Info(msg);
AddToBox(msg, Color.Black);
//clear();
}
public static void info(ILog log,string msg, Color color)
public static void info(ILog log, string msg, Color color)
{
log.Info( msg);
if (logBox == null)
{
return;
}
AddToBox(msg, color);
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);
AddToBox(msg, Color.Gray);
}
}
......@@ -94,61 +77,74 @@ namespace OnlineStore.Common
{
lastErrorLogTime.Add(type, DateTime.Now);
error(LOGGER, errorMsg);
}
}
}
}
public static void error(ILog log, string errorMsg)
{
if (errorMsg.Trim().Equals(""))
{
return;
}
//if (!lasErrorLogList.Contains(errorMsg))
{
log.Error( errorMsg);
if (logBox == null)
{
return;
}
AddToBox(errorMsg, Color.Red);
}
//lasErrorLogList.Add(errorMsg);
//if (lasErrorLogList.Count > errCount)
//{
// lasErrorLogList.RemoveAt(0);
//}
log.Error(errorMsg);
AddToBox(errorMsg, Color.Red);
}
private static void AddToBox(string msg, Color color)
{
try
{
ShowLogPro(msg, color);
{
ShowLogPro(msg, color);
}
catch (Exception ex)
{
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(0);
}
string text = "";
foreach (string str in logList)
{
text += str;
}
//logBox.SelectionColor = color;
System.DateTime now = System.DateTime.Now;
logBox.AppendText(now.ToLongTimeString() + " " + msg + Environment.NewLine);
count++;
logList.Add(now.ToLongTimeString() + " " + msg + Environment.NewLine);
if (logBox == null)
{
return;
}
logBox.Text = text;
// logBox.Focus(); //使文本框获取焦点
logBox.AppendText(now.ToLongTimeString() + " " + msg + Environment.NewLine); //增加文本
logBox.Select(logBox.Text.Length, 0); //设置光标的位置到文本尾
logBox.ScrollToCaret(); //滚动到控件光标处
}
catch (Exception ex)
{
LOGGER.Error("出错:" + ex.ToString());
}
}
public static void ClearLog()
{
if (logBox != null)
{
logList.Clear();
logBox.Text = "";
}
}
public static void debug(string msg)
{
......@@ -156,22 +152,12 @@ namespace OnlineStore.Common
}
public static void error(string errorMsg)
{
error( LOGGER,errorMsg);
error(LOGGER, errorMsg);
}
public static void ClearLog()
public static void info(string msg)
{
if (logBox != null)
{
logBox.Text = "";
count = 0;
}
info(LOGGER, msg);
}
public static void info(string msg)
{
info(LOGGER,msg );
}
}
}
......@@ -90,6 +90,7 @@ namespace OnlineStore.DeviceLibrary
lineStatus = LineStatus.OutStoreExecute;
MoveInfo.NewMove(LineMoveType.OutStore);
MoveInfo.MoveParam = new InOutParam();
serverShelfData = null;
if (IOValue(IO_Type.SL_Location_Check).Equals(IO_VALUE.HIGH))
{
FO_04_WaitTime();
......
......@@ -250,7 +250,7 @@ namespace OnlineStore.DeviceLibrary
paramMap.Add("barcode", barcode); // 参数: barcode=料盘的条码
paramMap.Add("rfid", rfid); // rfid = 料架的RFID信息
paramMap.Add("rfidLoc", rfidPosId); // rfidLoc=料架的架位信息
// paramMap.Add("robotIndex", "0"); // robotIndex = 机器人编号(非机器人放置时不传此参数), IP为51的机器人为1, 52的机器人为2, 53的机器人为3
// paramMap.Add("robotIndex", "0"); // robotIndex = r机器人编号(非机器人放置时不传此参数), IP为51的机器人为1, 52的机器人为2, 53的机器人为3
string server = GetAddr(Addr_putShelfFinished, paramMap);
string resultStr = HttpHelper.Post(server, "");
LogUtil.info("PutShelfFinished 【" + server + "】【" + resultStr + "】");
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!