Added: FS#3 - Filter buttons for log level
This commit is contained in:
parent
a9cf1b75f6
commit
bf0bb05983
@ -384,7 +384,7 @@ object MainForm: TMainForm
|
|||||||
Left = 552
|
Left = 552
|
||||||
Top = 176
|
Top = 176
|
||||||
Bitmap = {
|
Bitmap = {
|
||||||
494C01010200140038000C000C00FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
|
494C0101020014003C000C000C00FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
|
||||||
0000000000003600000028000000300000000C00000001002000000000000009
|
0000000000003600000028000000300000000C00000001002000000000000009
|
||||||
0000000000000000000000000000000000000000000000000000000000000000
|
0000000000000000000000000000000000000000000000000000000000000000
|
||||||
0000000000000000000000000000000000000000000000000000000000000000
|
0000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
@ -111,9 +111,10 @@ begin
|
|||||||
SetLogResourceString(@LogMonitorFormColumnMessage, 'Melding');
|
SetLogResourceString(@LogMonitorFormColumnMessage, 'Melding');
|
||||||
|
|
||||||
SetLogResourceString(@LogMonitorFormButtonClear, 'Wissen');
|
SetLogResourceString(@LogMonitorFormButtonClear, 'Wissen');
|
||||||
|
SetLogResourceString(@LogMonitorFormButtonPause, 'Pauzeren');
|
||||||
SetLogResourceString(@LogMonitorFormButtonCopyDetails, 'Kopieren');
|
SetLogResourceString(@LogMonitorFormButtonCopyDetails, 'Kopieren');
|
||||||
SetLogResourceString(@LogMonitorFormButtonSaveDetails, 'Opslaan');
|
SetLogResourceString(@LogMonitorFormButtonSaveDetails, 'Opslaan');
|
||||||
SetLogResourceString(@LogMonitorFormStatusPaused, 'Gepauseerd: %d melding(en) overgeslagen');
|
SetLogResourceString(@LogMonitorFormStatusPaused, 'Gepauzeerd: %d melding(en) overgeslagen');
|
||||||
|
|
||||||
SetLogResourceString(@LogMonitorFormSaveDetailsFilter, 'Alle bestanden (*.*)|*.*');
|
SetLogResourceString(@LogMonitorFormSaveDetailsFilter, 'Alle bestanden (*.*)|*.*');
|
||||||
|
|
||||||
@ -201,8 +202,7 @@ end;
|
|||||||
|
|
||||||
procedure TMainForm.btnMonitorFormClick(Sender: TObject);
|
procedure TMainForm.btnMonitorFormClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
// TX2LogObserverMonitorForm.ShowInstance(FLog);
|
TX2LogObserverMonitorForm.ShowInstance(FLog);
|
||||||
TX2LogObserverMonitorForm.ShowInstance(Tx2globallog.Instance);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,9 +40,12 @@ resourcestring
|
|||||||
|
|
||||||
{ Caption of the toolbar buttons }
|
{ Caption of the toolbar buttons }
|
||||||
LogMonitorFormButtonClear = 'Clear';
|
LogMonitorFormButtonClear = 'Clear';
|
||||||
|
LogMonitorFormButtonPause = 'Pause';
|
||||||
LogMonitorFormButtonCopyDetails = 'Copy';
|
LogMonitorFormButtonCopyDetails = 'Copy';
|
||||||
LogMonitorFormButtonSaveDetails = 'Save';
|
LogMonitorFormButtonSaveDetails = 'Save';
|
||||||
|
|
||||||
|
LogMonitorFormButtonFilter = 'Filter:';
|
||||||
|
|
||||||
{ Status messages }
|
{ Status messages }
|
||||||
LogMonitorFormStatusPaused = 'Paused: %d log message(s) skipped';
|
LogMonitorFormStatusPaused = 'Paused: %d log message(s) skipped';
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ uses
|
|||||||
|
|
||||||
type
|
type
|
||||||
TX2LogLevel = (Verbose, Info, Warning, Error);
|
TX2LogLevel = (Verbose, Info, Warning, Error);
|
||||||
|
TX2LogLevels = set of TX2LogLevel;
|
||||||
|
|
||||||
|
|
||||||
const
|
const
|
||||||
|
@ -148,7 +148,7 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
|
|||||||
end
|
end
|
||||||
item
|
item
|
||||||
Position = 2
|
Position = 2
|
||||||
Width = 428
|
Width = 424
|
||||||
WideText = 'Message'
|
WideText = 'Message'
|
||||||
end>
|
end>
|
||||||
end
|
end
|
||||||
@ -158,7 +158,7 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
|
|||||||
Width = 602
|
Width = 602
|
||||||
Height = 22
|
Height = 22
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
ButtonWidth = 56
|
ButtonWidth = 67
|
||||||
Caption = 'tbLog'
|
Caption = 'tbLog'
|
||||||
Images = ilsLog
|
Images = ilsLog
|
||||||
List = True
|
List = True
|
||||||
@ -175,6 +175,43 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
|
|||||||
Left = 56
|
Left = 56
|
||||||
Top = 0
|
Top = 0
|
||||||
Action = actPause
|
Action = actPause
|
||||||
|
AutoSize = True
|
||||||
|
Style = tbsCheck
|
||||||
|
end
|
||||||
|
object lblFilter: TLabel
|
||||||
|
Left = 116
|
||||||
|
Top = 0
|
||||||
|
Width = 46
|
||||||
|
Height = 22
|
||||||
|
Caption = ' Filter: '
|
||||||
|
Layout = tlCenter
|
||||||
|
end
|
||||||
|
object tbShowVerbose: TToolButton
|
||||||
|
Left = 162
|
||||||
|
Top = 0
|
||||||
|
Action = actShowVerbose
|
||||||
|
AutoSize = True
|
||||||
|
Style = tbsCheck
|
||||||
|
end
|
||||||
|
object tbShowInfo: TToolButton
|
||||||
|
Left = 232
|
||||||
|
Top = 0
|
||||||
|
Action = actShowInfo
|
||||||
|
AutoSize = True
|
||||||
|
Style = tbsCheck
|
||||||
|
end
|
||||||
|
object tbShowWarning: TToolButton
|
||||||
|
Left = 283
|
||||||
|
Top = 0
|
||||||
|
Action = actShowWarning
|
||||||
|
AutoSize = True
|
||||||
|
Style = tbsCheck
|
||||||
|
end
|
||||||
|
object tbShowError: TToolButton
|
||||||
|
Left = 354
|
||||||
|
Top = 0
|
||||||
|
Action = actShowError
|
||||||
|
AutoSize = True
|
||||||
Style = tbsCheck
|
Style = tbsCheck
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -196,7 +233,7 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
|
|||||||
Left = 448
|
Left = 448
|
||||||
Top = 48
|
Top = 48
|
||||||
Bitmap = {
|
Bitmap = {
|
||||||
494C0101090040009C0010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
|
494C010109004000B80010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
|
||||||
0000000000003600000028000000400000003000000001002000000000000030
|
0000000000003600000028000000400000003000000001002000000000000030
|
||||||
0000000000000000000000000000000000000000000000000000000000000000
|
0000000000000000000000000000000000000000000000000000000000000000
|
||||||
0000000000000000000000000000000000000000000000000000000000000000
|
0000000000000000000000000000000000000000000000000000000000000000
|
||||||
@ -626,6 +663,30 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
|
|||||||
ImageIndex = 8
|
ImageIndex = 8
|
||||||
OnExecute = actPauseExecute
|
OnExecute = actPauseExecute
|
||||||
end
|
end
|
||||||
|
object actShowVerbose: TAction
|
||||||
|
Caption = 'Verbose'
|
||||||
|
Checked = True
|
||||||
|
ImageIndex = 0
|
||||||
|
OnExecute = actShowVerboseExecute
|
||||||
|
end
|
||||||
|
object actShowInfo: TAction
|
||||||
|
Caption = 'Info'
|
||||||
|
Checked = True
|
||||||
|
ImageIndex = 1
|
||||||
|
OnExecute = actShowInfoExecute
|
||||||
|
end
|
||||||
|
object actShowWarning: TAction
|
||||||
|
Caption = 'Warning'
|
||||||
|
Checked = True
|
||||||
|
ImageIndex = 2
|
||||||
|
OnExecute = actShowWarningExecute
|
||||||
|
end
|
||||||
|
object actShowError: TAction
|
||||||
|
Caption = 'Error'
|
||||||
|
Checked = True
|
||||||
|
ImageIndex = 3
|
||||||
|
OnExecute = actShowErrorExecute
|
||||||
|
end
|
||||||
end
|
end
|
||||||
object sdDetails: TSaveDialog
|
object sdDetails: TSaveDialog
|
||||||
Options = [ofOverwritePrompt, ofHideReadOnly, ofEnableSizing]
|
Options = [ofOverwritePrompt, ofHideReadOnly, ofEnableSizing]
|
||||||
|
@ -51,6 +51,15 @@ type
|
|||||||
actPause: TAction;
|
actPause: TAction;
|
||||||
tbPause: TToolButton;
|
tbPause: TToolButton;
|
||||||
sdDetails: TSaveDialog;
|
sdDetails: TSaveDialog;
|
||||||
|
tbShowVerbose: TToolButton;
|
||||||
|
tbShowInfo: TToolButton;
|
||||||
|
tbShowWarning: TToolButton;
|
||||||
|
tbShowError: TToolButton;
|
||||||
|
actShowVerbose: TAction;
|
||||||
|
actShowInfo: TAction;
|
||||||
|
actShowWarning: TAction;
|
||||||
|
actShowError: TAction;
|
||||||
|
lblFilter: TLabel;
|
||||||
|
|
||||||
procedure FormShow(Sender: TObject);
|
procedure FormShow(Sender: TObject);
|
||||||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||||||
@ -65,6 +74,10 @@ type
|
|||||||
procedure actSaveDetailsExecute(Sender: TObject);
|
procedure actSaveDetailsExecute(Sender: TObject);
|
||||||
procedure actPauseExecute(Sender: TObject);
|
procedure actPauseExecute(Sender: TObject);
|
||||||
procedure ToolbarCustomDraw(Sender: TToolBar; const ARect: TRect; var DefaultDraw: Boolean);
|
procedure ToolbarCustomDraw(Sender: TToolBar; const ARect: TRect; var DefaultDraw: Boolean);
|
||||||
|
procedure actShowVerboseExecute(Sender: TObject);
|
||||||
|
procedure actShowInfoExecute(Sender: TObject);
|
||||||
|
procedure actShowWarningExecute(Sender: TObject);
|
||||||
|
procedure actShowErrorExecute(Sender: TObject);
|
||||||
private class var
|
private class var
|
||||||
FInstances: TMonitorFormDictionary;
|
FInstances: TMonitorFormDictionary;
|
||||||
private
|
private
|
||||||
@ -73,8 +86,7 @@ type
|
|||||||
FLogAttached: Boolean;
|
FLogAttached: Boolean;
|
||||||
FPausedLogCount: Integer;
|
FPausedLogCount: Integer;
|
||||||
FDetails: IX2LogDetails;
|
FDetails: IX2LogDetails;
|
||||||
|
FVisibleLevels: TX2LogLevels;
|
||||||
function GetPaused: Boolean;
|
|
||||||
protected
|
protected
|
||||||
class function GetInstance(ALog: IX2LogObservable; out AForm: TX2LogObserverMonitorForm): Boolean;
|
class function GetInstance(ALog: IX2LogObservable; out AForm: TX2LogObserverMonitorForm): Boolean;
|
||||||
class procedure RemoveInstance(AForm: TX2LogObserverMonitorForm);
|
class procedure RemoveInstance(AForm: TX2LogObserverMonitorForm);
|
||||||
@ -87,6 +99,10 @@ type
|
|||||||
|
|
||||||
procedure UpdateUI;
|
procedure UpdateUI;
|
||||||
procedure UpdateStatus;
|
procedure UpdateStatus;
|
||||||
|
procedure UpdateFilter;
|
||||||
|
|
||||||
|
function GetPaused: Boolean;
|
||||||
|
procedure ToggleVisibleLevel(AAction: TObject; ALevel: TX2LogLevel);
|
||||||
|
|
||||||
procedure SetDetails(ADetails: IX2LogDetails);
|
procedure SetDetails(ADetails: IX2LogDetails);
|
||||||
procedure SetBinaryDetails(ADetails: IX2LogDetailsBinary);
|
procedure SetBinaryDetails(ADetails: IX2LogDetailsBinary);
|
||||||
@ -96,6 +112,7 @@ type
|
|||||||
property LogAttached: Boolean read FLogAttached;
|
property LogAttached: Boolean read FLogAttached;
|
||||||
property Paused: Boolean read GetPaused;
|
property Paused: Boolean read GetPaused;
|
||||||
property PausedLogCount: Integer read FPausedLogCount write FPausedLogCount;
|
property PausedLogCount: Integer read FPausedLogCount write FPausedLogCount;
|
||||||
|
property VisibleLevels: TX2LogLevels read FVisibleLevels write FVisibleLevels;
|
||||||
public
|
public
|
||||||
class function Instance(ALog: IX2LogObservable): TX2LogObserverMonitorForm;
|
class function Instance(ALog: IX2LogObservable): TX2LogObserverMonitorForm;
|
||||||
|
|
||||||
@ -145,6 +162,8 @@ const
|
|||||||
ColumnTime = 1;
|
ColumnTime = 1;
|
||||||
ColumnMessage = 2;
|
ColumnMessage = 2;
|
||||||
|
|
||||||
|
LevelImageIndex: array[TX2LogLevel] of TImageIndex = (0, 1, 2, 3);
|
||||||
|
|
||||||
|
|
||||||
{ TLogEntryNode }
|
{ TLogEntryNode }
|
||||||
procedure TLogEntryNodeData.Initialize(ALevel: TX2LogLevel; const AMessage: string; ADetails: IX2LogDetails);
|
procedure TLogEntryNodeData.Initialize(ALevel: TX2LogLevel; const AMessage: string; ADetails: IX2LogDetails);
|
||||||
@ -249,12 +268,20 @@ begin
|
|||||||
vstLog.Header.Columns[ColumnTime].Text := GetLogResourceString(@LogMonitorFormColumnTime);
|
vstLog.Header.Columns[ColumnTime].Text := GetLogResourceString(@LogMonitorFormColumnTime);
|
||||||
vstLog.Header.Columns[ColumnMessage].Text := GetLogResourceString(@LogMonitorFormColumnMessage);
|
vstLog.Header.Columns[ColumnMessage].Text := GetLogResourceString(@LogMonitorFormColumnMessage);
|
||||||
|
|
||||||
tbClear.Caption := GetLogResourceString(@LogMonitorFormButtonClear);
|
actClear.Caption := GetLogResourceString(@LogMonitorFormButtonClear);
|
||||||
tbCopyDetails.Caption := GetLogResourceString(@LogMonitorFormButtonCopyDetails);
|
actPause.Caption := GetLogResourceString(@LogMonitorFormButtonPause);
|
||||||
tbSaveDetails.Caption := GetLogResourceString(@LogMonitorFormButtonSaveDetails);
|
actCopyDetails.Caption := GetLogResourceString(@LogMonitorFormButtonCopyDetails);
|
||||||
|
actSaveDetails.Caption := GetLogResourceString(@LogMonitorFormButtonSaveDetails);
|
||||||
|
|
||||||
sdDetails.Filter := GetLogResourceString(@LogMonitorFormSaveDetailsFilter);
|
sdDetails.Filter := GetLogResourceString(@LogMonitorFormSaveDetailsFilter);
|
||||||
|
|
||||||
|
lblFilter.Caption := ' ' + GetLogResourceString(@LogMonitorFormButtonFilter) + ' ';
|
||||||
|
actShowVerbose.Caption := GetLogLevelText(TX2LogLevel.Verbose);
|
||||||
|
actShowInfo.Caption := GetLogLevelText(TX2LogLevel.Info);
|
||||||
|
actShowWarning.Caption := GetLogLevelText(TX2LogLevel.Warning);
|
||||||
|
actShowError.Caption := GetLogLevelText(TX2LogLevel.Error);
|
||||||
|
|
||||||
|
FVisibleLevels := [Low(TX2LogLevel)..High(TX2LogLevel)];
|
||||||
UpdateUI;
|
UpdateUI;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -325,6 +352,8 @@ begin
|
|||||||
nodeData := vstLog.GetNodeData(node);
|
nodeData := vstLog.GetNodeData(node);
|
||||||
nodeData^.Initialize(ALevel, AMessage, ADetails);
|
nodeData^.Initialize(ALevel, AMessage, ADetails);
|
||||||
|
|
||||||
|
vstLog.IsVisible[node] := (ALevel in VisibleLevels);
|
||||||
|
|
||||||
if scroll then
|
if scroll then
|
||||||
vstLog.ScrollIntoView(node, False);
|
vstLog.ScrollIntoView(node, False);
|
||||||
|
|
||||||
@ -367,6 +396,43 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TX2LogObserverMonitorForm.UpdateFilter;
|
||||||
|
var
|
||||||
|
node: PVirtualNode;
|
||||||
|
nodeData: PLogEntryNodeData;
|
||||||
|
|
||||||
|
begin
|
||||||
|
vstLog.BeginUpdate;
|
||||||
|
try
|
||||||
|
for node in vstLog.Nodes do
|
||||||
|
begin
|
||||||
|
nodeData := vstLog.GetNodeData(node);
|
||||||
|
vstLog.IsVisible[node] := (nodeData^.Level in VisibleLevels);
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
vstLog.EndUpdate;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function TX2LogObserverMonitorForm.GetPaused: Boolean;
|
||||||
|
begin
|
||||||
|
Result := actPause.Checked;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TX2LogObserverMonitorForm.ToggleVisibleLevel(AAction: TObject; ALevel: TX2LogLevel);
|
||||||
|
begin
|
||||||
|
if ALevel in VisibleLevels then
|
||||||
|
Exclude(FVisibleLevels, ALevel)
|
||||||
|
else
|
||||||
|
Include(FVisibleLevels, ALevel);
|
||||||
|
|
||||||
|
(AAction as TCustomAction).Checked := (ALevel in VisibleLevels);
|
||||||
|
UpdateFilter;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TX2LogObserverMonitorForm.SetDetails(ADetails: IX2LogDetails);
|
procedure TX2LogObserverMonitorForm.SetDetails(ADetails: IX2LogDetails);
|
||||||
var
|
var
|
||||||
logDetailsBinary: IX2LogDetailsBinary;
|
logDetailsBinary: IX2LogDetailsBinary;
|
||||||
@ -487,12 +553,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TX2LogObserverMonitorForm.GetPaused: Boolean;
|
|
||||||
begin
|
|
||||||
Result := actPause.Checked;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure TX2LogObserverMonitorForm.vstLogInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode;
|
procedure TX2LogObserverMonitorForm.vstLogInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode;
|
||||||
var InitialStates: TVirtualNodeInitStates);
|
var InitialStates: TVirtualNodeInitStates);
|
||||||
var
|
var
|
||||||
@ -559,12 +619,7 @@ begin
|
|||||||
|
|
||||||
case Column of
|
case Column of
|
||||||
ColumnLevel:
|
ColumnLevel:
|
||||||
case nodeData^.Level of
|
ImageIndex := LevelImageIndex[nodeData^.Level];
|
||||||
TX2LogLevel.Verbose: ImageIndex := 0;
|
|
||||||
TX2LogLevel.Info: ImageIndex := 1;
|
|
||||||
TX2LogLevel.Warning: ImageIndex := 2;
|
|
||||||
TX2LogLevel.Error: ImageIndex := 3;
|
|
||||||
end;
|
|
||||||
|
|
||||||
ColumnMessage:
|
ColumnMessage:
|
||||||
if Assigned(nodeData^.Details) then
|
if Assigned(nodeData^.Details) then
|
||||||
@ -635,6 +690,30 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TX2LogObserverMonitorForm.actShowVerboseExecute(Sender: TObject);
|
||||||
|
begin
|
||||||
|
ToggleVisibleLevel(Sender, TX2LogLevel.Verbose);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TX2LogObserverMonitorForm.actShowInfoExecute(Sender: TObject);
|
||||||
|
begin
|
||||||
|
ToggleVisibleLevel(Sender, TX2LogLevel.Info);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TX2LogObserverMonitorForm.actShowWarningExecute(Sender: TObject);
|
||||||
|
begin
|
||||||
|
ToggleVisibleLevel(Sender, TX2LogLevel.Warning);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TX2LogObserverMonitorForm.actShowErrorExecute(Sender: TObject);
|
||||||
|
begin
|
||||||
|
ToggleVisibleLevel(Sender, TX2LogLevel.Error);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TX2LogObserverMonitorForm.ToolbarCustomDraw(Sender: TToolBar; const ARect: TRect; var DefaultDraw: Boolean);
|
procedure TX2LogObserverMonitorForm.ToolbarCustomDraw(Sender: TToolBar; const ARect: TRect; var DefaultDraw: Boolean);
|
||||||
var
|
var
|
||||||
element: TThemedElementDetails;
|
element: TThemedElementDetails;
|
||||||
|
Loading…
Reference in New Issue
Block a user