Finished proper DateTime support
Added Copy functionality for dictionary details to monitor form
This commit is contained in:
parent
dee64510b6
commit
f124ccd0c2
@ -358,7 +358,7 @@ object MainForm: TMainForm
|
|||||||
Margins.Top = 8
|
Margins.Top = 8
|
||||||
Margins.Right = 8
|
Margins.Right = 8
|
||||||
Margins.Bottom = 0
|
Margins.Bottom = 0
|
||||||
ActivePage = tsTimer
|
ActivePage = tsStructured
|
||||||
Align = alTop
|
Align = alTop
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
object tsText: TTabSheet
|
object tsText: TTabSheet
|
||||||
@ -609,7 +609,7 @@ object MainForm: TMainForm
|
|||||||
Left = 552
|
Left = 552
|
||||||
Top = 176
|
Top = 176
|
||||||
Bitmap = {
|
Bitmap = {
|
||||||
494C0101020014005C000C000C00FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
|
494C01010200140060000C000C00FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
|
||||||
0000000000003600000028000000300000000C00000001002000000000000009
|
0000000000003600000028000000300000000C00000001002000000000000009
|
||||||
0000000000000000000000000000000000000000000000000000000000000000
|
0000000000000000000000000000000000000000000000000000000000000000
|
||||||
0000000000000000000000000000000000000000000000000000000000000000
|
0000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
@ -476,7 +476,7 @@ procedure TMainForm.btnValueTypesClick(Sender: TObject);
|
|||||||
begin
|
begin
|
||||||
FLog.InfoS('Testing the various value types',
|
FLog.InfoS('Testing the various value types',
|
||||||
['String', 'Hello world!',
|
['String', 'Hello world!',
|
||||||
'DateTime', Now,
|
'DateTime', LogDT,
|
||||||
'Has the large hadron collider destroyed the world yet?', False,
|
'Has the large hadron collider destroyed the world yet?', False,
|
||||||
'Float', 3.1415,
|
'Float', 3.1415,
|
||||||
'Integer', 89740987342]);
|
'Integer', 89740987342]);
|
||||||
|
@ -331,6 +331,7 @@ var
|
|||||||
param: TVarRec;
|
param: TVarRec;
|
||||||
key: string;
|
key: string;
|
||||||
value: TX2LogDictionaryValue;
|
value: TX2LogDictionaryValue;
|
||||||
|
logDateTime: IX2LogDateTime;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
@ -375,6 +376,12 @@ begin
|
|||||||
vtPWideChar: value := TX2LogDictionaryStringValue.Create(param.VPWideChar);
|
vtPWideChar: value := TX2LogDictionaryStringValue.Create(param.VPWideChar);
|
||||||
vtAnsiString: value := TX2LogDictionaryStringValue.Create(PChar(param.VAnsiString));
|
vtAnsiString: value := TX2LogDictionaryStringValue.Create(PChar(param.VAnsiString));
|
||||||
vtCurrency: value := TX2LogDictionaryFloatValue.Create(param.VCurrency^);
|
vtCurrency: value := TX2LogDictionaryFloatValue.Create(param.VCurrency^);
|
||||||
|
vtInterface:
|
||||||
|
if Supports(IInterface(param.VInterface), IX2LogDateTime, logDateTime) then
|
||||||
|
value := TX2LogDictionaryDateTimeValue.Create(logDateTime.Value)
|
||||||
|
else
|
||||||
|
raise Exception.CreateFmt('Unsupported value type %d at index %d', [param.VType, paramIndex]);
|
||||||
|
|
||||||
vtWideString: value := TX2LogDictionaryStringValue.Create(WideString(param.VWideString));
|
vtWideString: value := TX2LogDictionaryStringValue.Create(WideString(param.VWideString));
|
||||||
vtInt64: value := TX2LogDictionaryIntValue.Create(param.VInt64^);
|
vtInt64: value := TX2LogDictionaryIntValue.Create(param.VInt64^);
|
||||||
{$IF CompilerVersion >= 23}
|
{$IF CompilerVersion >= 23}
|
||||||
|
@ -109,7 +109,8 @@ type
|
|||||||
|
|
||||||
{ Use this wrapper when passing a TDateTime to one of the structured logging
|
{ Use this wrapper when passing a TDateTime to one of the structured logging
|
||||||
methods, otherwise Delphi will pass it as a floating point value. }
|
methods, otherwise Delphi will pass it as a floating point value. }
|
||||||
function DT(AValue: TDateTime): IX2LogDateTime;
|
function LogDT: IX2LogDateTime; overload;
|
||||||
|
function LogDT(AValue: TDateTime): IX2LogDateTime; overload;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -125,7 +126,13 @@ type
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function DT(AValue: TDateTime): IX2LogDateTime;
|
function LogDT: IX2LogDateTime;
|
||||||
|
begin
|
||||||
|
Result := LogDT(Now);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function LogDT(AValue: TDateTime): IX2LogDateTime;
|
||||||
begin
|
begin
|
||||||
Result := TX2LogDateTime.Create(AValue);
|
Result := TX2LogDateTime.Create(AValue);
|
||||||
end;
|
end;
|
||||||
|
@ -144,7 +144,7 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
|
|||||||
Align = alClient
|
Align = alClient
|
||||||
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goColSizing, goAlwaysShowEditor, goThumbTracking]
|
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goColSizing, goAlwaysShowEditor, goThumbTracking]
|
||||||
TabOrder = 3
|
TabOrder = 3
|
||||||
ExplicitTop = 0
|
OnKeyDown = vleDetailsDictionaryKeyDown
|
||||||
ColWidths = (
|
ColWidths = (
|
||||||
150
|
150
|
||||||
142)
|
142)
|
||||||
@ -284,7 +284,7 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
|
|||||||
Left = 448
|
Left = 448
|
||||||
Top = 48
|
Top = 48
|
||||||
Bitmap = {
|
Bitmap = {
|
||||||
494C01010A004000FC0010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
|
494C01010A004000000110001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
|
||||||
0000000000003600000028000000400000003000000001002000000000000030
|
0000000000003600000028000000400000003000000001002000000000000030
|
||||||
0000000000000000000000000000000000000000000000000000000000000000
|
0000000000000000000000000000000000000000000000000000000000000000
|
||||||
0000000000000000000000000000000000000000000000000000000000000000
|
0000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
@ -11,15 +11,17 @@ uses
|
|||||||
Vcl.Dialogs,
|
Vcl.Dialogs,
|
||||||
Vcl.ExtCtrls,
|
Vcl.ExtCtrls,
|
||||||
Vcl.Forms,
|
Vcl.Forms,
|
||||||
|
Vcl.Grids,
|
||||||
Vcl.ImgList,
|
Vcl.ImgList,
|
||||||
Vcl.Menus,
|
Vcl.Menus,
|
||||||
Vcl.StdCtrls,
|
Vcl.StdCtrls,
|
||||||
Vcl.ToolWin,
|
Vcl.ToolWin,
|
||||||
|
Vcl.ValEdit,
|
||||||
VirtualTrees,
|
VirtualTrees,
|
||||||
Winapi.Messages,
|
Winapi.Messages,
|
||||||
|
|
||||||
X2Log.Details.Intf,
|
X2Log.Details.Intf,
|
||||||
X2Log.Intf, Vcl.Grids, Vcl.ValEdit;
|
X2Log.Intf;
|
||||||
|
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -34,6 +36,8 @@ type
|
|||||||
TX2LogObserverMonitorForm = class;
|
TX2LogObserverMonitorForm = class;
|
||||||
TMonitorFormDictionary = TObjectDictionary<IX2LogObservable,TX2LogObserverMonitorForm>;
|
TMonitorFormDictionary = TObjectDictionary<IX2LogObservable,TX2LogObserverMonitorForm>;
|
||||||
|
|
||||||
|
TCopyHandler = procedure of object;
|
||||||
|
|
||||||
|
|
||||||
TX2LogObserverMonitorForm = class(TForm, IX2LogObserver)
|
TX2LogObserverMonitorForm = class(TForm, IX2LogObserver)
|
||||||
vstLog: TVirtualStringTree;
|
vstLog: TVirtualStringTree;
|
||||||
@ -103,6 +107,7 @@ type
|
|||||||
procedure vstLogGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: string);
|
procedure vstLogGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: string);
|
||||||
procedure vstLogGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex; var Ghosted: Boolean; var ImageIndex: Integer);
|
procedure vstLogGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex; var Ghosted: Boolean; var ImageIndex: Integer);
|
||||||
procedure vstLogFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex);
|
procedure vstLogFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex);
|
||||||
|
procedure vleDetailsDictionaryKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
procedure actCloseExecute(Sender: TObject);
|
procedure actCloseExecute(Sender: TObject);
|
||||||
procedure actClearExecute(Sender: TObject);
|
procedure actClearExecute(Sender: TObject);
|
||||||
procedure actCopyDetailsExecute(Sender: TObject);
|
procedure actCopyDetailsExecute(Sender: TObject);
|
||||||
@ -129,6 +134,7 @@ type
|
|||||||
FVisibleLevels: TX2LogLevels;
|
FVisibleLevels: TX2LogLevels;
|
||||||
FMaxEntries: Cardinal;
|
FMaxEntries: Cardinal;
|
||||||
FWordWrap: Boolean;
|
FWordWrap: Boolean;
|
||||||
|
FCopyHandler: TCopyHandler;
|
||||||
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);
|
||||||
@ -153,6 +159,7 @@ type
|
|||||||
procedure SetBinaryDetails(ADetails: IX2LogDetailsBinary);
|
procedure SetBinaryDetails(ADetails: IX2LogDetailsBinary);
|
||||||
procedure SetGraphicDetails(ADetails: IX2LogDetailsGraphic);
|
procedure SetGraphicDetails(ADetails: IX2LogDetailsGraphic);
|
||||||
procedure SetDictionaryDetails(ADetails: IX2LogDetailsDictionary);
|
procedure SetDictionaryDetails(ADetails: IX2LogDetailsDictionary);
|
||||||
|
procedure CopyDictionaryDetails;
|
||||||
|
|
||||||
procedure SetVisibleDetails(AControl: TControl);
|
procedure SetVisibleDetails(AControl: TControl);
|
||||||
procedure SetWordWrap(AValue: Boolean);
|
procedure SetWordWrap(AValue: Boolean);
|
||||||
@ -376,6 +383,7 @@ begin
|
|||||||
actShowError.Caption := GetLogLevelText(TX2LogLevel.Error);
|
actShowError.Caption := GetLogLevelText(TX2LogLevel.Error);
|
||||||
|
|
||||||
FVisibleLevels := [Low(TX2LogLevel)..High(TX2LogLevel)];
|
FVisibleLevels := [Low(TX2LogLevel)..High(TX2LogLevel)];
|
||||||
|
SetVisibleDetails(nil);
|
||||||
UpdateUI;
|
UpdateUI;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -597,6 +605,7 @@ var
|
|||||||
begin
|
begin
|
||||||
FDetails := ADetails;
|
FDetails := ADetails;
|
||||||
canWrap := False;
|
canWrap := False;
|
||||||
|
FCopyHandler := nil;
|
||||||
|
|
||||||
if Assigned(Details) then
|
if Assigned(Details) then
|
||||||
begin
|
begin
|
||||||
@ -619,7 +628,7 @@ begin
|
|||||||
SetVisibleDetails(nil);
|
SetVisibleDetails(nil);
|
||||||
|
|
||||||
|
|
||||||
actCopyDetails.Enabled := Supports(ADetails, IX2LogDetailsCopyable);
|
actCopyDetails.Enabled := Assigned(FCopyHandler) or Supports(ADetails, IX2LogDetailsCopyable);
|
||||||
actSaveDetails.Enabled := Supports(ADetails, IX2LogDetailsStreamable);
|
actSaveDetails.Enabled := Supports(ADetails, IX2LogDetailsStreamable);
|
||||||
actWordWrap.Enabled := canWrap;
|
actWordWrap.Enabled := canWrap;
|
||||||
actWordWrap.Checked := canWrap and FWordWrap;
|
actWordWrap.Checked := canWrap and FWordWrap;
|
||||||
@ -756,10 +765,33 @@ begin
|
|||||||
vleDetailsDictionary.Values[key] := displayValue;
|
vleDetailsDictionary.Values[key] := displayValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
FCopyHandler := CopyDictionaryDetails;
|
||||||
SetVisibleDetails(vleDetailsDictionary);
|
SetVisibleDetails(vleDetailsDictionary);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TX2LogObserverMonitorForm.CopyDictionaryDetails;
|
||||||
|
var
|
||||||
|
y: Integer;
|
||||||
|
x: Integer;
|
||||||
|
selectedText: TStringBuilder;
|
||||||
|
|
||||||
|
begin
|
||||||
|
selectedText := TStringBuilder.Create;
|
||||||
|
try
|
||||||
|
for y := vleDetailsDictionary.Selection.Top to vleDetailsDictionary.Selection.Bottom do
|
||||||
|
begin
|
||||||
|
for x := vleDetailsDictionary.Selection.Left to vleDetailsDictionary.Selection.Right do
|
||||||
|
selectedText.Append(vleDetailsDictionary.Cells[x, y]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Clipboard.AsText := selectedText.ToString;
|
||||||
|
finally
|
||||||
|
FreeAndNil(selectedText);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TX2LogObserverMonitorForm.SetVisibleDetails(AControl: TControl);
|
procedure TX2LogObserverMonitorForm.SetVisibleDetails(AControl: TControl);
|
||||||
begin
|
begin
|
||||||
if Assigned(AControl) then
|
if Assigned(AControl) then
|
||||||
@ -878,6 +910,16 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TX2LogObserverMonitorForm.vleDetailsDictionaryKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
|
begin
|
||||||
|
if (Shift = [ssCtrl]) and (Key = Ord('C')) then
|
||||||
|
begin
|
||||||
|
CopyDictionaryDetails;
|
||||||
|
Key := 0;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TX2LogObserverMonitorForm.actCloseExecute(Sender: TObject);
|
procedure TX2LogObserverMonitorForm.actCloseExecute(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
Close;
|
Close;
|
||||||
@ -898,7 +940,10 @@ var
|
|||||||
logDetailsCopyable: IX2LogDetailsCopyable;
|
logDetailsCopyable: IX2LogDetailsCopyable;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if Supports(Details, IX2LogDetailsCopyable, logDetailsCopyable) then
|
if Assigned(FCopyHandler) then
|
||||||
|
FCopyHandler
|
||||||
|
|
||||||
|
else if Supports(Details, IX2LogDetailsCopyable, logDetailsCopyable) then
|
||||||
logDetailsCopyable.CopyToClipboard;
|
logDetailsCopyable.CopyToClipboard;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user