ttw_fmx_v10/fLog.pas

95 lines
2.3 KiB
Plaintext

unit fLog;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes,
System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
System.Rtti, FMX.Grid.Style, System.Generics.Collections, FMX.Grid,
FMX.ScrollBox,
FMX.Controls.Presentation, uRecords;
type
TfrLog = class(TFrame)
Panel1: TPanel;
btnClear: TButton;
chkWARNING: TCheckBox;
chkERROR: TCheckBox;
chkDEBUG: TCheckBox;
chkINFO: TCheckBox;
sgLog: TStringGrid;
StringColumn5: TStringColumn;
StringColumn1: TStringColumn;
StringColumn2: TStringColumn;
StringColumn3: TStringColumn;
StringColumn4: TStringColumn;
procedure btnClearClick(Sender: TObject);
procedure chkWARNINGChange(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
FLogList: TList<TRLog>;
destructor Destroy; override;
procedure UpdateGridFilters;
end;
implementation
{$R *.fmx}
{ TfrLog }
procedure TfrLog.chkWARNINGChange(Sender: TObject);
begin
UpdateGridFilters;
end;
destructor TfrLog.Destroy;
begin
FLogList.Free;
inherited;
end;
procedure TfrLog.btnClearClick(Sender: TObject);
begin
FLogList.Clear;
UpdateGridFilters;
end;
procedure TfrLog.UpdateGridFilters;
var
ml: TRLog;
NewRow: integer;
begin
sgLog.BeginUpdate;
try
sgLog.RowCount := 0;
// Ïðîâåðêà íàëè÷èÿ âñåõ êîëîíîê
if sgLog.ColumnCount < 5 then
raise Exception.Create('Ãðèä äîëæåí ñîäåðæàòü 5 êîëîíîê.');
for ml in FLogList do
begin
// Ïðîâåðêà ôèëüòðà
if ((ml.rType = 'WARNING') and chkWARNING.IsChecked) or
((ml.rType = 'ERROR') and chkERROR.IsChecked) or
((ml.rType = 'DEBUG') and chkDEBUG.IsChecked) or
((ml.rType = 'INFO') and chkINFO.IsChecked) then
begin
sgLog.RowCount := sgLog.RowCount + 1;
NewRow := sgLog.RowCount - 1;
// Çàïîëíåíèå äàííûõ ñ ïðîâåðêîé êîëîíîê
sgLog.Cells[0, NewRow] := TimeToStr(ml.rTime); // Êîëîíêà 0
sgLog.Cells[1, NewRow] := ml.rType; // Êîëîíêà 1
sgLog.Cells[2, NewRow] := ml.rModule; // Êîëîíêà 2
sgLog.Cells[3, NewRow] := ml.rMethod; // Êîëîíêà 3
sgLog.Cells[4, NewRow] := ml.rMessage; // Êîëîíêà 4
end;
end;
finally
sgLog.EndUpdate;
end;
end;
end.