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 用の out-of-band フラグメントをレンダリングします。
Theme(ltDark / ltLight)、WrapLines、Height、TimeFormat、EmptyText で見た目を調整します。