1
0
mirror of synced 2024-11-08 22:29:16 +00:00

Added displaying of dictionary details to monitor form

This commit is contained in:
Mark van Renswoude 2016-10-14 17:02:27 +02:00
parent 1a22728f30
commit 24dc9481bd
4 changed files with 81 additions and 6 deletions

View File

@ -26,7 +26,7 @@ object MainForm: TMainForm
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
ActivePage = tsRollingFile
ActivePage = tsNamedPipe
Align = alClient
Images = ilsObservers
TabOrder = 0
@ -531,6 +531,19 @@ object MainForm: TMainForm
OnClick = btnTimerStopClick
end
end
object tsStructured: TTabSheet
Caption = 'Structured'
ImageIndex = 4
object btnValueTypes: TButton
Left = 12
Top = 15
Width = 121
Height = 21
Caption = 'Value types test'
TabOrder = 0
OnClick = btnValueTypesClick
end
end
end
object pnlDispatch: TPanel
AlignWithMargins = True
@ -596,7 +609,7 @@ object MainForm: TMainForm
Left = 552
Top = 176
Bitmap = {
494C01010200140058000C000C00FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
494C0101020014005C000C000C00FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000300000000C00000001002000000000000009
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000

View File

@ -79,6 +79,8 @@ type
rbRollingAbsolute: TRadioButton;
lblRollingDays: TLabel;
edtRollingDays: TEdit;
tsStructured: TTabSheet;
btnValueTypes: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
@ -105,6 +107,7 @@ type
procedure TimerTimer(Sender: TObject);
procedure btnRollingFileStartClick(Sender: TObject);
procedure btnRollingFileStopClick(Sender: TObject);
procedure btnValueTypesClick(Sender: TObject);
private
FLog: IX2Log;
FEventObserver: IX2LogObserver;
@ -468,4 +471,15 @@ begin
FLog.Info('Message 3');
end;
procedure TMainForm.btnValueTypesClick(Sender: TObject);
begin
FLog.InfoS('Testing the various value types',
['String', 'Hello world!',
'DateTime', Now,
'Has the large hadron collider destroyed the world yet?', False,
'Float', 3.1415,
'Integer', 89740987342]);
end;
end.

View File

@ -136,6 +136,19 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
AutoSize = True
end
end
object vleDetailsDictionary: TValueListEditor
Left = 0
Top = 19
Width = 298
Height = 451
Align = alClient
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goColSizing, goAlwaysShowEditor, goThumbTracking]
TabOrder = 3
ExplicitTop = 0
ColWidths = (
150
142)
end
end
end
object pnlLog: TPanel
@ -266,14 +279,12 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
Margins.Bottom = 0
Panels = <>
SimplePanel = True
ExplicitLeft = 20
ExplicitTop = 503
end
object ilsLog: TImageList
Left = 448
Top = 48
Bitmap = {
494C01010A004000F80010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
494C01010A004000FC0010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000003000000001002000000000000030
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000

View File

@ -19,7 +19,7 @@ uses
Winapi.Messages,
X2Log.Details.Intf,
X2Log.Intf;
X2Log.Intf, Vcl.Grids, Vcl.ValEdit;
const
@ -95,6 +95,7 @@ type
mmMainFileSep1: TMenuItem;
mmMainFileSaveAs: TMenuItem;
sdSaveAs: TSaveDialog;
vleDetailsDictionary: TValueListEditor;
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
@ -151,6 +152,7 @@ type
procedure SetDetails(ADetails: IX2LogDetails);
procedure SetBinaryDetails(ADetails: IX2LogDetailsBinary);
procedure SetGraphicDetails(ADetails: IX2LogDetailsGraphic);
procedure SetDictionaryDetails(ADetails: IX2LogDetailsDictionary);
procedure SetVisibleDetails(AControl: TControl);
procedure SetWordWrap(AValue: Boolean);
@ -588,6 +590,7 @@ procedure TX2LogObserverMonitorForm.SetDetails(ADetails: IX2LogDetails);
var
logDetailsGraphic: IX2LogDetailsGraphic;
logDetailsBinary: IX2LogDetailsBinary;
logDetailsDictionary: IX2LogDetailsDictionary;
logDetailsText: IX2LogDetailsText;
canWrap: Boolean;
@ -603,6 +606,9 @@ begin
else if Supports(ADetails, IX2LogDetailsBinary, logDetailsBinary) then
SetBinaryDetails(logDetailsBinary)
else if Supports(ADetails, IX2LogDetailsDictionary, logDetailsDictionary) then
SetDictionaryDetails(logDetailsDictionary)
else if Supports(ADetails, IX2LogDetailsText, logDetailsText) then
begin
reDetails.Text := logDetailsText.AsString;
@ -727,6 +733,33 @@ begin
end;
procedure TX2LogObserverMonitorForm.SetDictionaryDetails(ADetails: IX2LogDetailsDictionary);
var
key: string;
displayValue: string;
begin
vleDetailsDictionary.Strings.Clear;
for key in ADetails.Keys do
begin
displayValue := '<error>';
case ADetails.ValueType[key] of
StringValue: displayValue := ADetails.StringValue[key];
BooleanValue: displayValue := BoolToStr(ADetails.BooleanValue[key], True);
IntValue: displayValue := IntToStr(ADetails.IntValue[key]);
FloatValue: displayValue := FormatFloat('0.########', ADetails.FloatValue[key]);
DateTimeValue: displayValue := DateTimeToStr(ADetails.DateTimeValue[key]);
end;
vleDetailsDictionary.Values[key] := displayValue;
end;
SetVisibleDetails(vleDetailsDictionary);
end;
procedure TX2LogObserverMonitorForm.SetVisibleDetails(AControl: TControl);
begin
if Assigned(AControl) then
@ -737,12 +770,16 @@ begin
reDetails.Visible := (AControl = reDetails);
sbDetailsImage.Visible := (AControl = sbDetailsImage);
vleDetailsDictionary.Visible := (AControl = vleDetailsDictionary);
if not reDetails.Visible then
reDetails.Clear;
if not sbDetailsImage.Visible then
imgDetailsImage.Picture.Assign(nil);
if not vleDetailsDictionary.Visible then
vleDetailsDictionary.Strings.Clear;
end;