LogViewer 컴포넌트 — sgcHTML | eSeGeCe

LogViewer

TsgcHTMLComponent_LogViewer — Delphi, C++ Builder 및 .NET에서 레벨 필터, 검색, 자동 스크롤, 다크/라이트 테마를 갖춘 스트리밍 로그/터미널 뷰어입니다.

TsgcHTMLComponent_LogViewer

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는 버퍼를 비웁니다.

레벨

TsgcHTMLLogLevelllTrace, llDebug, llInfo, llWarning, llError, llFatal — 각각 Theme에 따라 색상으로 구분됩니다.

툴바

ShowSearch, ShowLevelFilterTitle이 툴바를 제어합니다. 필터링과 하이라이트는 서버 왕복 없이 클라이언트 측에서 실행됩니다.

자동 스크롤

AutoScroll은 최신 라인을 따라갑니다. ShowAutoScrollToggle은 체크박스를 추가하여 사용자가 위로 스크롤하는 동안 자동 추적을 일시 중지할 수 있게 합니다.

스트리밍 업데이트

GetLastLineFragmentHTML / GetLineFragmentHTML(aIndex)TsgcHTMX_Engine_Server.PushFragment / BroadcastFragment용 대역 외 프래그먼트를 렌더링합니다.

모양

Theme(ltDark / ltLight), WrapLines, Height, TimeFormatEmptyText가 모양을 조정합니다.

계속 살펴보기

온라인 도움말이 찱포넌트의 전체 API 참조 및 사용 가이드입니다.
모든 sgcHTML 컴포넌트80개 이상의 컴포넌트 전체 기능 매트릭스를 둘러보십시오.
무료 체험판 다운로드30일 체험판에는 60.HTML 데모 프로젝트가 포함됩니다.
가격전체 소스 코드가 포함된 Single, Team 및 Site 라이선스.

시작할 준비가 되셨습니까?

무료 체험판을 다운로드하고 Delphi, C++ Builder 또는 .NET 웹 앱에 실시간 로그 뷰어를 추가하십시오.