YOUSEFUL / DELPHI / COMPONENTS

TAtlasLogFormatter

The abstract base of the formatters: one event in, one line of text out.

Class Unit Atlas.LogFormat · Inherits TObject · Product Atlas Log

Description

Implemented by TAtlasTextFormatter and TAtlasJsonFormatter. Write code against it to accept either.

Members

MemberKindWhat it does
FormatmethodThe event as one line, without a line break at the end.

Methods

Format method

function Format(const Event: TAtlasLogEvent): string; virtual; abstract;

The event as one line, without a line break at the end.

Examples

Format a snapshot either way

The caller chooses text or JSON.

pascal
uses Atlas.Log, Atlas.LogFormat;

function FormatAll(const Events: TArray<TAtlasLogEvent>; Formatter: TAtlasLogFormatter): TArray<string>;
var
  I: Integer;
begin
  SetLength(Result, Length(Events));
  for I := 0 to High(Events) do Result[I] := Formatter.Format(Events[I]);
end;

TAtlasTextFormatter · TAtlasJsonFormatter

Also in Atlas Log

TAtlasLogger · TAtlasMemorySink · TAtlasCallbackSink · TAtlasConsoleSink · TAtlasDebugSink · TAtlasFileSink · TAtlasAsyncSink · TAtlasLogView