LogViewer
TsgcHTMLComponent_LogViewer — Delphi, C++ Builder 및 .NET에서 레벨 필터, 검색, 자동 스크롤, 다크/라이트 테마를 갖춘 스트리밍 로그/터미널 뷰어입니다.
TsgcHTMLComponent_LogViewer — Delphi, C++ Builder 및 .NET에서 레벨 필터, 검색, 자동 스크롤, 다크/라이트 테마를 갖춘 스트리밍 로그/터미널 뷰어입니다.
AddLine으로 라인을 추가하면 상한이 있는 링 버퍼에 보관되며, 이후 HTML 속성을 읽습니다 — 또는 GetLastLineFragmentHTML로 연결된 클라이언트에 새 라인을 스트리밍합니다.
TsgcHTMLComponent_LogViewer
툴바 + 터미널 스타일 로그 본문 + 범위 지정 CSS
Delphi, C++ Builder, .NET
각 항목에 대해 AddLine을 호출하고, 초기 렌더링을 위해 HTML을 읽은 다음, GetLastLineFragmentHTML로 열려 있는 WebSocket 클라이언트에 새 라인을 푸시합니다.
uses
sgcHTML_Component_LogViewer;
var
oLog: TsgcHTMLComponent_LogViewer;
begin
oLog := TsgcHTMLComponent_LogViewer.Create(nil);
try
oLog.LogID := 'applog';
oLog.Theme := ltDark;
oLog.MaxLines := 500;
oLog.Height := '400px';
oLog.AddLine(llInfo, 'Service started', 'app');
oLog.AddLine(llWarning, 'Low disk space', 'monitor');
oLog.AddLine(llError, 'Connection refused', 'db');
WebModule.Response := oLog.HTML; // toolbar + log body + inline script
finally
oLog.Free;
end;
end;
// Push one more line to every connected client, no full re-render:
oLog.AddLine(llInfo, 'New order received', 'orders');
TsgcHTMX_Engine_Server.BroadcastFragment(oLog.GetLastLineFragmentHTML);
// includes: sgcHTML_Component_LogViewer.hpp
TsgcHTMLComponent_LogViewer *oLog = new TsgcHTMLComponent_LogViewer(NULL);
try
{
oLog->LogID = "applog";
oLog->Theme = ltDark;
oLog->MaxLines = 500;
oLog->Height = "400px";
oLog->AddLine(llInfo, "Service started", "app");
oLog->AddLine(llWarning, "Low disk space", "monitor");
oLog->AddLine(llError, "Connection refused", "db");
String html = oLog->HTML; // toolbar + log body + inline script
// Push one more line to every connected client:
oLog->AddLine(llInfo, "New order received", "orders");
TsgcHTMX_Engine_Server::BroadcastFragment(oLog->GetLastLineFragmentHTML());
}
__finally
{
delete oLog;
}
using esegece.sgcWebSockets;
var log = new TsgcHTMLComponent_LogViewer();
log.LogID = "applog";
log.Theme = TsgcHTMLLogTheme.ltDark;
log.MaxLines = 500;
log.Height = "400px";
log.AddLine(TsgcHTMLLogLevel.llInfo, "Service started", "app");
log.AddLine(TsgcHTMLLogLevel.llWarning, "Low disk space", "monitor");
log.AddLine(TsgcHTMLLogLevel.llError, "Connection refused", "db");
string html = log.HTML; // toolbar + log body + inline script
// Push one more line to every connected client, no full re-render:
log.AddLine(TsgcHTMLLogLevel.llInfo, "New order received", "orders");
TsgcHTMX_Engine_Server.BroadcastFragment(log.GetLastLineFragmentHTML());
가장 자주 사용하게 되는 멤버.
AddLine(aLevel, aText, aSource)는 타임스탬프가 찍힌 항목을 추가합니다. MaxLines(기본값 500)는 링 버퍼의 상한을 정하고 가장 오래된 라인을 제거합니다. Clear는 버퍼를 비웁니다.
TsgcHTMLLogLevel — llTrace, llDebug, llInfo, llWarning, llError, llFatal — 각각 Theme에 따라 색상으로 구분됩니다.
ShowSearch, ShowLevelFilter 및 Title이 툴바를 제어합니다. 필터링과 하이라이트는 서버 왕복 없이 클라이언트 측에서 실행됩니다.
AutoScroll은 최신 라인을 따라갑니다. ShowAutoScrollToggle은 체크박스를 추가하여 사용자가 위로 스크롤하는 동안 자동 추적을 일시 중지할 수 있게 합니다.
GetLastLineFragmentHTML / GetLineFragmentHTML(aIndex)는 TsgcHTMX_Engine_Server.PushFragment / BroadcastFragment용 대역 외 프래그먼트를 렌더링합니다.
Theme(ltDark / ltLight), WrapLines, Height, TimeFormat 및 EmptyText가 모양을 조정합니다.