LogViewer Component — sgcHTML | eSeGeCe

LogViewer

TsgcHTMLComponent_LogViewer — a streaming log / terminal viewer with level filter, search, auto-scroll and dark/light themes, in Delphi, C++ Builder and .NET.

TsgcHTMLComponent_LogViewer

Push lines with AddLine, they are kept in a capped ring buffer, then read the HTML property — or stream new lines to connected clients with GetLastLineFragmentHTML.

Component class

TsgcHTMLComponent_LogViewer

Renders

Toolbar + terminal-style log body + scoped CSS

Languages

Delphi, C++ Builder, .NET

Add lines, render it, stream updates

Call AddLine for each entry, read HTML for the initial render, then push new lines to open WebSocket clients with GetLastLineFragmentHTML.

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());

Key properties & methods

The members you reach for most often.

Adding lines

AddLine(aLevel, aText, aSource) appends a timestamped entry; MaxLines (default 500) caps the ring buffer and drops the oldest line. Clear empties it.

Levels

TsgcHTMLLogLevelllTrace, llDebug, llInfo, llWarning, llError, llFatal — each colour-coded per Theme.

Toolbar

ShowSearch, ShowLevelFilter and Title control the toolbar; filtering and highlighting run client-side, no round-trip.

Auto-scroll

AutoScroll follows the newest line; ShowAutoScrollToggle adds a checkbox so the reader can pause following while scrolling back.

Streaming updates

GetLastLineFragmentHTML / GetLineFragmentHTML(aIndex) render an out-of-band fragment for TsgcHTMX_Engine_Server.PushFragment / BroadcastFragment.

Appearance

Theme (ltDark / ltLight), WrapLines, Height, TimeFormat and EmptyText tune the look.

Keep exploring

Online HelpFull API reference and usage guide for this component.
All sgcHTML ComponentsBrowse the full feature matrix of 80+ components.
Download Free TrialThe 30-day trial ships the 60.HTML demo projects.
PricingSingle, Team and Site licenses with full source code.

Ready to Get Started?

Download the free trial and add a live log viewer to your Delphi, C++ Builder or .NET web app.