From 61ac290c2897f69db9d879ea4968304ddcd23d40 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期五, 01 八月 2025 19:22:54 +0800
Subject: [PATCH] 1. 添加日志文件

---
 SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp |   39 +++++++++++++++++++++++++++++++++++++--
 1 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp b/SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp
index b946b61..eb946f3 100644
--- a/SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp
+++ b/SourceCode/Bond/SGMeasurement/SGMeasurementDlg.cpp
@@ -8,6 +8,7 @@
 #include "SGMeasurementDlg.h"
 #include "afxdialogex.h"
 #include "SGIF.h"
+#include "Logger.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -175,7 +176,7 @@
 	m_editLog.ReplaceSel(_T(""));   // 鍒犻櫎
 }
 
-void CSGMeasurementDlg::AppendLogLineRichStyled(const CString& content, COLORREF color /*= RGB(0, 0, 0)*/)
+void CSGMeasurementDlg::AppendLogLineRichStyled(const CString& strContent, COLORREF color /*= RGB(0, 0, 0)*/)
 {
 	if (!::IsWindow(GetSafeHwnd()) || !::IsWindow(m_editLog.GetSafeHwnd())) {
 		return;
@@ -197,16 +198,41 @@
 	m_editLog.SetSelectionCharFormat(cfTime);
 	m_editLog.ReplaceSel(strTimestamp);
 
+	// 鐢熸垚鏃ュ織绾у埆鏍囩
+	CString strLevel;
+	if (color == LOG_COLOR_WARNING) {
+		strLevel = _T("[璀﹀憡]");
+	}
+	else if (color == LOG_COLOR_ERROR) {
+		strLevel = _T("[閿欒]");
+	}
+	else if (color == LOG_COLOR_NORMAL) {
+		strLevel = _T("[淇℃伅]");
+	}
+	else if (color == LOG_COLOR_SUCCESS) {
+		strLevel = _T("[鎴愬姛]");
+	}
+	else {
+		strLevel = _T("[鏈煡]");
+	}
+
 	// 鎻掑叆鏃ュ織姝f枃锛堜紶鍏ラ鑹诧級
 	CHARFORMAT2 cfMsg = {};
 	cfMsg.cbSize = sizeof(cfMsg);
 	cfMsg.dwMask = CFM_COLOR;
 	cfMsg.crTextColor = color;
 	m_editLog.SetSelectionCharFormat(cfMsg);
-	m_editLog.ReplaceSel(content + _T("\r\n"));
+	m_editLog.ReplaceSel(strLevel + strContent + _T("\r\n"));
 
 	// 闄愬埗鏈�澶ц鏁�
 	TrimRichEditLineLimit(100);
+
+	// 鎷兼帴瀹屾暣鏃ュ織琛�
+	CString strFullLogLine;
+	strFullLogLine.Format(_T("%s %s"), strLevel, strContent);
+
+	// 鍐欏叆鏃ュ織鏂囦欢
+	LOG_LINE(strFullLogLine);
 }
 
 void CSGMeasurementDlg::HighlightAllMatches(const CString& strSearch, COLORREF clrHighlight/* = RGB(255, 165, 0)*/)
@@ -614,6 +640,8 @@
 		return -1.0f;
 	}
 
+	clock_t startClock = clock();  // 璁板綍寮�濮嬫椂闂�
+
 	std::vector<float> vecBuffer(m_nSavePointCount, 0.0f);
 	int nReceived = 0;
 
@@ -648,6 +676,13 @@
 		CalcGlassOffset(vecGlass1, vecGlass2, fAvg1, fAvg2, fOffset);
 	}
 
+	clock_t endClock = clock();  // 璁板綍缁撴潫鏃堕棿
+	double dElapsedMs = 1000.0 * (endClock - startClock) / CLOCKS_PER_SEC;
+
+	CString strElapsed;
+	strElapsed.Format(_T("AnalyzeStoredData 鎵ц鑰楁椂锛�%.1f ms"), dElapsedMs);
+	AppendLogLineRichStyled(strElapsed, LOG_COLOR_SUCCESS);
+
 	return fOffset;
 }
 

--
Gitblit v1.9.3