2014-05-18 18:09:07 +00:00
|
|
|
unit MainFrm;
|
|
|
|
|
|
|
|
interface
|
|
|
|
uses
|
|
|
|
System.Classes,
|
|
|
|
Vcl.ComCtrls,
|
|
|
|
Vcl.Controls,
|
|
|
|
Vcl.ExtCtrls,
|
|
|
|
Vcl.Forms,
|
2014-08-18 12:07:33 +00:00
|
|
|
Vcl.ImgList,
|
2014-05-18 18:09:07 +00:00
|
|
|
Vcl.StdCtrls,
|
|
|
|
|
2019-10-30 14:01:19 +00:00
|
|
|
X2Log.Intf, System.ImageList;
|
2014-05-18 18:09:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
TMainForm = class(TForm)
|
|
|
|
btnClose: TButton;
|
2014-05-20 19:17:23 +00:00
|
|
|
btnVerbose: TButton;
|
2014-05-18 18:09:07 +00:00
|
|
|
edtMessage: TEdit;
|
|
|
|
lblMessage: TLabel;
|
|
|
|
mmoEvent: TMemo;
|
|
|
|
pcObservers: TPageControl;
|
|
|
|
pnlButtons: TPanel;
|
|
|
|
tsEvent: TTabSheet;
|
|
|
|
tsFile: TTabSheet;
|
|
|
|
lblException: TLabel;
|
|
|
|
edtException: TEdit;
|
|
|
|
btnException: TButton;
|
|
|
|
tsNamedPipe: TTabSheet;
|
2014-05-20 08:49:57 +00:00
|
|
|
btnMonitorForm: TButton;
|
2014-05-20 19:17:23 +00:00
|
|
|
btnInfo: TButton;
|
|
|
|
btnWarning: TButton;
|
|
|
|
btnError: TButton;
|
2014-05-25 14:20:58 +00:00
|
|
|
btnEventStart: TButton;
|
|
|
|
btnEventStop: TButton;
|
|
|
|
ilsObservers: TImageList;
|
|
|
|
btnFileStart: TButton;
|
|
|
|
btnFileStop: TButton;
|
|
|
|
btnNamedPipeStart: TButton;
|
|
|
|
btnNamedPipeStop: TButton;
|
|
|
|
edtFilename: TEdit;
|
|
|
|
lblFilename: TLabel;
|
|
|
|
rbProgramData: TRadioButton;
|
|
|
|
rbUserData: TRadioButton;
|
|
|
|
rbAbsolute: TRadioButton;
|
|
|
|
edtPipeName: TEdit;
|
|
|
|
lblPipeName: TLabel;
|
2014-06-01 13:32:21 +00:00
|
|
|
btnBinaryRawByteString: TButton;
|
2014-05-31 11:14:05 +00:00
|
|
|
pcDispatch: TPageControl;
|
|
|
|
tsText: TTabSheet;
|
|
|
|
tsException: TTabSheet;
|
|
|
|
tsBinary: TTabSheet;
|
|
|
|
pnlDispatch: TPanel;
|
|
|
|
bvlDispatch: TBevel;
|
2014-05-31 20:10:10 +00:00
|
|
|
pnlObservers: TPanel;
|
|
|
|
bvlObservers: TBevel;
|
2014-06-01 13:32:21 +00:00
|
|
|
btnGraphic: TButton;
|
2014-08-18 12:07:33 +00:00
|
|
|
lblNamedPipeServers: TLabel;
|
|
|
|
btnNamedPipeRefresh: TButton;
|
|
|
|
lbNamedPipeServers: TListBox;
|
2014-08-19 10:50:59 +00:00
|
|
|
btnLock: TButton;
|
|
|
|
btnUnlock: TButton;
|
2014-10-20 12:07:44 +00:00
|
|
|
btnCategory: TButton;
|
2014-10-22 18:24:54 +00:00
|
|
|
tsTimer: TTabSheet;
|
|
|
|
lblTimer: TLabel;
|
|
|
|
lblInterval: TLabel;
|
|
|
|
edtInterval: TEdit;
|
|
|
|
btnTimerStart: TButton;
|
|
|
|
btnTimerStop: TButton;
|
|
|
|
Timer: TTimer;
|
2015-03-06 11:51:59 +00:00
|
|
|
tsRollingFile: TTabSheet;
|
|
|
|
lblRollingFileName: TLabel;
|
|
|
|
btnRollingFileStart: TButton;
|
|
|
|
btnRollingFileStop: TButton;
|
|
|
|
edtRollingFileName: TEdit;
|
|
|
|
rbRollingProgramData: TRadioButton;
|
|
|
|
rbRollingUserData: TRadioButton;
|
|
|
|
rbRollingAbsolute: TRadioButton;
|
|
|
|
lblRollingDays: TLabel;
|
|
|
|
edtRollingDays: TEdit;
|
2016-10-14 15:02:27 +00:00
|
|
|
tsStructured: TTabSheet;
|
|
|
|
btnValueTypes: TButton;
|
2016-10-15 09:22:51 +00:00
|
|
|
pnlFileTextFormatter: TPanel;
|
|
|
|
rbFileTextFormatterDefault: TRadioButton;
|
|
|
|
rbFileTextFormatterJson: TRadioButton;
|
|
|
|
pnlRollingFileTextFormatter: TPanel;
|
|
|
|
rbRollingFileTextFormatterDefault: TRadioButton;
|
|
|
|
rbRollingFileTextFormatterJson: TRadioButton;
|
2017-04-26 15:20:48 +00:00
|
|
|
btnStructuredException: TButton;
|
2014-05-18 18:09:07 +00:00
|
|
|
|
|
|
|
procedure FormCreate(Sender: TObject);
|
|
|
|
procedure FormDestroy(Sender: TObject);
|
2014-05-20 19:17:23 +00:00
|
|
|
procedure btnCloseClick(Sender: TObject);
|
|
|
|
procedure btnLogClick(Sender: TObject);
|
2014-05-18 18:09:07 +00:00
|
|
|
procedure edtExceptionKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
|
|
|
procedure edtMessageKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
|
|
|
procedure btnExceptionClick(Sender: TObject);
|
2014-05-20 08:49:57 +00:00
|
|
|
procedure btnMonitorFormClick(Sender: TObject);
|
2014-08-19 10:50:59 +00:00
|
|
|
procedure btnLockClick(Sender: TObject);
|
|
|
|
procedure btnUnlockClick(Sender: TObject);
|
2014-05-25 14:20:58 +00:00
|
|
|
procedure btnEventStartClick(Sender: TObject);
|
|
|
|
procedure btnEventStopClick(Sender: TObject);
|
|
|
|
procedure btnFileStartClick(Sender: TObject);
|
|
|
|
procedure btnFileStopClick(Sender: TObject);
|
|
|
|
procedure btnNamedPipeStartClick(Sender: TObject);
|
|
|
|
procedure btnNamedPipeStopClick(Sender: TObject);
|
2014-06-01 13:32:21 +00:00
|
|
|
procedure btnBinaryRawByteStringClick(Sender: TObject);
|
|
|
|
procedure btnGraphicClick(Sender: TObject);
|
2014-08-18 12:07:33 +00:00
|
|
|
procedure btnNamedPipeRefreshClick(Sender: TObject);
|
2014-10-20 12:07:44 +00:00
|
|
|
procedure btnCategoryClick(Sender: TObject);
|
2014-10-22 18:24:54 +00:00
|
|
|
procedure btnTimerStartClick(Sender: TObject);
|
|
|
|
procedure btnTimerStopClick(Sender: TObject);
|
|
|
|
procedure TimerTimer(Sender: TObject);
|
2015-03-06 11:51:59 +00:00
|
|
|
procedure btnRollingFileStartClick(Sender: TObject);
|
|
|
|
procedure btnRollingFileStopClick(Sender: TObject);
|
2016-10-14 15:02:27 +00:00
|
|
|
procedure btnValueTypesClick(Sender: TObject);
|
2017-04-26 15:20:48 +00:00
|
|
|
procedure btnStructuredExceptionClick(Sender: TObject);
|
2014-05-18 18:09:07 +00:00
|
|
|
private
|
|
|
|
FLog: IX2Log;
|
2014-05-25 14:20:58 +00:00
|
|
|
FEventObserver: IX2LogObserver;
|
|
|
|
FFileObserver: IX2LogObserver;
|
2015-03-06 11:51:59 +00:00
|
|
|
FRollingFileObserver: IX2LogObserver;
|
2014-05-25 14:20:58 +00:00
|
|
|
FNamedPipeObserver: IX2LogObserver;
|
2014-05-18 18:09:07 +00:00
|
|
|
protected
|
2014-10-20 12:07:44 +00:00
|
|
|
procedure DoLog(Sender: TObject; Level: TX2LogLevel; DateTime: TDateTime; const Msg, Category: string; Details: IX2LogDetails);
|
2014-05-18 18:09:07 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
|
|
|
System.SysUtils,
|
2014-06-01 13:32:21 +00:00
|
|
|
Vcl.Imaging.Jpeg,
|
2014-05-18 18:09:07 +00:00
|
|
|
Winapi.Windows,
|
|
|
|
|
|
|
|
X2Log,
|
2014-08-18 12:07:33 +00:00
|
|
|
X2Log.Client.NamedPipe,
|
2014-05-18 18:09:07 +00:00
|
|
|
X2Log.Constants,
|
2014-05-30 12:51:01 +00:00
|
|
|
X2Log.Details.Default,
|
2014-06-01 13:32:21 +00:00
|
|
|
X2Log.Details.Intf,
|
2014-08-18 12:07:33 +00:00
|
|
|
X2Log.Exception.madExceptHandler,
|
2014-05-18 18:09:07 +00:00
|
|
|
X2Log.Observer.Event,
|
|
|
|
X2Log.Observer.LogFile,
|
2014-05-20 08:49:57 +00:00
|
|
|
X2Log.Observer.MonitorForm,
|
2014-05-31 11:14:05 +00:00
|
|
|
X2Log.Observer.NamedPipe,
|
2015-03-06 11:51:59 +00:00
|
|
|
X2Log.Observer.RollingLogFile,
|
2016-10-15 09:22:51 +00:00
|
|
|
X2Log.TextFormatter.Intf,
|
|
|
|
X2Log.TextFormatter.Json,
|
2014-05-31 11:14:05 +00:00
|
|
|
X2Log.Global;
|
2014-05-18 18:09:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
|
|
{ TMainForm }
|
|
|
|
procedure TMainForm.FormCreate(Sender: TObject);
|
|
|
|
begin
|
2014-05-20 08:49:57 +00:00
|
|
|
{ Testing the localization (Dutch) }
|
2014-05-18 18:09:07 +00:00
|
|
|
SetLogResourceString(@LogLevelVerbose, 'Uitgebreid');
|
|
|
|
SetLogResourceString(@LogLevelInfo, 'Informatie');
|
|
|
|
SetLogResourceString(@LogLevelWarning, 'Waarschuwing');
|
|
|
|
SetLogResourceString(@LogLevelError, 'Fout');
|
|
|
|
|
2014-05-20 08:49:57 +00:00
|
|
|
SetLogResourceString(@LogMonitorFormColumnTime, 'Tijd');
|
|
|
|
SetLogResourceString(@LogMonitorFormColumnMessage, 'Melding');
|
|
|
|
|
2014-05-20 09:19:04 +00:00
|
|
|
SetLogResourceString(@LogMonitorFormButtonClear, 'Wissen');
|
2014-05-31 20:47:52 +00:00
|
|
|
SetLogResourceString(@LogMonitorFormButtonPause, 'Pauzeren');
|
2014-05-20 19:17:23 +00:00
|
|
|
SetLogResourceString(@LogMonitorFormButtonCopyDetails, 'Kopieren');
|
2014-05-20 09:19:04 +00:00
|
|
|
SetLogResourceString(@LogMonitorFormButtonSaveDetails, 'Opslaan');
|
2014-05-31 20:47:52 +00:00
|
|
|
SetLogResourceString(@LogMonitorFormStatusPaused, 'Gepauzeerd: %d melding(en) overgeslagen');
|
2014-05-20 09:19:04 +00:00
|
|
|
|
2014-05-30 13:06:47 +00:00
|
|
|
SetLogResourceString(@LogMonitorFormSaveDetailsFilter, 'Alle bestanden (*.*)|*.*');
|
|
|
|
|
2014-05-18 18:09:07 +00:00
|
|
|
FLog := TX2Log.Create;
|
|
|
|
FLog.SetExceptionStrategy(TX2LogmadExceptExceptionStrategy.Create);
|
|
|
|
|
2014-05-31 11:14:05 +00:00
|
|
|
pcDispatch.ActivePageIndex := 0;
|
2014-05-18 18:09:07 +00:00
|
|
|
pcObservers.ActivePageIndex := 0;
|
2014-08-19 10:50:59 +00:00
|
|
|
|
|
|
|
DefaultMaxEntries := 10;
|
2014-05-18 18:09:07 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TMainForm.FormDestroy(Sender: TObject);
|
|
|
|
begin
|
|
|
|
FLog := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-10-20 12:07:44 +00:00
|
|
|
procedure TMainForm.DoLog(Sender: TObject; Level: TX2LogLevel; DateTime: TDateTime; const Msg, Category: string; Details: IX2LogDetails);
|
2014-05-30 12:51:01 +00:00
|
|
|
var
|
|
|
|
text: string;
|
|
|
|
logDetailsText: IX2LogDetailsText;
|
|
|
|
|
2014-05-18 18:09:07 +00:00
|
|
|
begin
|
2014-10-20 12:07:44 +00:00
|
|
|
text := GetLogLevelText(Level) + ': ' + Category + ': ' + Msg;
|
2014-05-30 12:51:01 +00:00
|
|
|
|
|
|
|
if Supports(Details, IX2LogDetailsText, logDetailsText) then
|
|
|
|
text := text + ' (' + logDetailsText.AsString + ')';
|
|
|
|
|
|
|
|
mmoEvent.Lines.Add(text);
|
2014-05-18 18:09:07 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TMainForm.edtMessageKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
|
|
|
begin
|
|
|
|
if Key = VK_RETURN then
|
|
|
|
begin
|
|
|
|
btnException.Click;
|
|
|
|
Key := 0;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TMainForm.edtExceptionKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
|
|
|
begin
|
|
|
|
if Key = VK_RETURN then
|
|
|
|
begin
|
|
|
|
btnException.Click;
|
|
|
|
Key := 0;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2014-10-20 12:07:44 +00:00
|
|
|
|
2014-05-20 19:17:23 +00:00
|
|
|
procedure TMainForm.btnCloseClick(Sender: TObject);
|
2014-05-18 18:09:07 +00:00
|
|
|
begin
|
2014-05-20 19:17:23 +00:00
|
|
|
Close;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TMainForm.btnLogClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if Sender = btnVerbose then
|
|
|
|
FLog.Verbose(edtMessage.Text)
|
|
|
|
else if Sender = btnInfo then
|
|
|
|
FLog.Info(edtMessage.Text)
|
|
|
|
else if Sender = btnWarning then
|
|
|
|
FLog.Warning(edtMessage.Text)
|
|
|
|
else if Sender = btnError then
|
2014-06-01 13:32:21 +00:00
|
|
|
FLog.Error(edtMessage.Text);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TMainForm.btnBinaryRawByteStringClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
FLog.InfoEx(edtMessage.Text, TX2LogBinaryDetails.Create(#0#1#2#3'Test'#12'Some more data'));
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TMainForm.btnGraphicClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
graphic: TJPEGImage;
|
|
|
|
resourceStream: TResourceStream;
|
|
|
|
|
|
|
|
begin
|
|
|
|
graphic := TJPEGImage.Create;
|
|
|
|
try
|
|
|
|
resourceStream := TResourceStream.Create(SysInit.HInstance, 'GraphicDetails', RT_RCDATA);
|
|
|
|
try
|
|
|
|
graphic.LoadFromStream(resourceStream);
|
|
|
|
finally
|
|
|
|
FreeAndNil(resourceStream);
|
|
|
|
end;
|
|
|
|
|
|
|
|
FLog.InfoEx('Graphic', TX2LogGraphicDetails.Create(graphic));
|
|
|
|
finally
|
|
|
|
FreeAndNil(graphic);
|
|
|
|
end;
|
2014-05-18 18:09:07 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TMainForm.btnExceptionClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
try
|
|
|
|
{ Throw an actual exception, don't just create it, to allow
|
|
|
|
strategies like madExcept to do their stack trace }
|
|
|
|
raise EAbort.Create(edtException.Text);
|
|
|
|
except
|
|
|
|
on E:Exception do
|
|
|
|
FLog.Exception(E);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2014-05-20 08:49:57 +00:00
|
|
|
|
2014-10-20 12:07:44 +00:00
|
|
|
procedure TMainForm.btnCategoryClick(Sender: TObject);
|
2015-03-19 08:56:52 +00:00
|
|
|
|
|
|
|
procedure Category2(ALog: IX2Log);
|
|
|
|
begin
|
|
|
|
ALog.Info(edtMessage.Text);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure Category1(ALog: IX2Log);
|
|
|
|
begin
|
|
|
|
ALog.Info('Category 1');
|
|
|
|
Category2(ALog.Category('Sub-category'));
|
|
|
|
ALog.Info('/Category 1');
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-10-20 12:07:44 +00:00
|
|
|
begin
|
2015-03-19 08:56:52 +00:00
|
|
|
FLog.Info('Categories');
|
|
|
|
Category1(FLog.Category('Test'));
|
|
|
|
FLog.Info('/Categories');
|
2014-10-20 12:07:44 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-20 08:49:57 +00:00
|
|
|
procedure TMainForm.btnMonitorFormClick(Sender: TObject);
|
|
|
|
begin
|
2014-05-31 20:47:52 +00:00
|
|
|
TX2LogObserverMonitorForm.ShowInstance(FLog);
|
2014-05-20 08:49:57 +00:00
|
|
|
end;
|
|
|
|
|
2014-05-25 14:20:58 +00:00
|
|
|
|
2014-08-19 10:50:59 +00:00
|
|
|
procedure TMainForm.btnLockClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
TX2LogObserverMonitorForm.LockInstance(FLog);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TMainForm.btnUnlockClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
TX2LogObserverMonitorForm.UnlockInstance(FLog);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-25 14:20:58 +00:00
|
|
|
procedure TMainForm.btnEventStartClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if not Assigned(FEventObserver) then
|
|
|
|
begin
|
|
|
|
FEventObserver := TX2LogEventObserver.Create(DoLog);
|
|
|
|
FLog.Attach(FEventObserver);
|
|
|
|
|
|
|
|
tsEvent.ImageIndex := 1;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TMainForm.btnEventStopClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if Assigned(FEventObserver) then
|
|
|
|
begin
|
|
|
|
FLog.Detach(FEventObserver);
|
|
|
|
FEventObserver := nil;
|
|
|
|
|
|
|
|
tsEvent.ImageIndex := 0;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TMainForm.btnFileStartClick(Sender: TObject);
|
2016-10-15 09:22:51 +00:00
|
|
|
var
|
|
|
|
textFormatter: IX2LogTextFormatter;
|
|
|
|
|
2014-05-25 14:20:58 +00:00
|
|
|
begin
|
|
|
|
if not Assigned(FFileObserver) then
|
|
|
|
begin
|
2016-10-15 09:22:51 +00:00
|
|
|
textFormatter := nil;
|
|
|
|
if rbFileTextFormatterJson.Checked then
|
|
|
|
textFormatter := TX2LogJsonTextFormatter.Create;
|
|
|
|
|
2014-05-25 14:20:58 +00:00
|
|
|
if rbProgramData.Checked then
|
2016-10-15 09:22:51 +00:00
|
|
|
FFileObserver := TX2LogFileObserver.CreateInProgramData(edtFilename.Text, X2LogLevelsDefault, True, textFormatter)
|
2014-05-25 14:20:58 +00:00
|
|
|
else if rbUserData.Checked then
|
2016-10-15 09:22:51 +00:00
|
|
|
FFileObserver := TX2LogFileObserver.CreateInUserAppData(edtFilename.Text, X2LogLevelsDefault, True, textFormatter)
|
2014-05-25 14:20:58 +00:00
|
|
|
else
|
2016-10-15 09:22:51 +00:00
|
|
|
FFileObserver := TX2LogFileObserver.Create(edtFilename.Text, X2LogLevelsDefault, True, textFormatter);
|
2014-05-25 14:20:58 +00:00
|
|
|
|
|
|
|
FLog.Attach(FFileObserver);
|
|
|
|
|
|
|
|
tsFile.ImageIndex := 1;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TMainForm.btnFileStopClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if Assigned(FFileObserver) then
|
|
|
|
begin
|
|
|
|
FLog.Detach(FFileObserver);
|
|
|
|
FFileObserver := nil;
|
|
|
|
|
|
|
|
tsFile.ImageIndex := 0;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2015-03-06 11:51:59 +00:00
|
|
|
procedure TMainForm.btnRollingFileStartClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
days: Integer;
|
2016-10-15 09:22:51 +00:00
|
|
|
textFormatter: IX2LogTextFormatter;
|
2015-03-06 11:51:59 +00:00
|
|
|
|
|
|
|
begin
|
|
|
|
if not Assigned(FRollingFileObserver) then
|
|
|
|
begin
|
2016-10-15 09:22:51 +00:00
|
|
|
textFormatter := nil;
|
|
|
|
if rbFileTextFormatterJson.Checked then
|
|
|
|
textFormatter := TX2LogJsonTextFormatter.Create;
|
|
|
|
|
2015-03-06 11:51:59 +00:00
|
|
|
days := StrToIntDef(edtRollingDays.Text, 7);
|
|
|
|
|
|
|
|
if rbRollingProgramData.Checked then
|
2016-10-15 09:22:51 +00:00
|
|
|
FRollingFileObserver := TX2RollingLogFileObserver.CreateInProgramData(edtFilename.Text, days, X2LogLevelsDefault, True, textFormatter)
|
2015-03-06 11:51:59 +00:00
|
|
|
else if rbRollingUserData.Checked then
|
2016-10-15 09:22:51 +00:00
|
|
|
FRollingFileObserver := TX2RollingLogFileObserver.CreateInUserAppData(edtFilename.Text, days, X2LogLevelsDefault, True, textFormatter)
|
2015-03-06 11:51:59 +00:00
|
|
|
else
|
2016-10-15 09:22:51 +00:00
|
|
|
FRollingFileObserver := TX2RollingLogFileObserver.Create(edtFilename.Text, days, X2LogLevelsDefault, True, textFormatter);
|
2015-03-06 11:51:59 +00:00
|
|
|
|
|
|
|
FLog.Attach(FRollingFileObserver);
|
|
|
|
|
|
|
|
tsRollingFile.ImageIndex := 1;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TMainForm.btnRollingFileStopClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if Assigned(FRollingFileObserver) then
|
|
|
|
begin
|
|
|
|
FLog.Detach(FRollingFileObserver);
|
|
|
|
FRollingFileObserver := nil;
|
|
|
|
|
|
|
|
tsRollingFile.ImageIndex := 0;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-25 14:20:58 +00:00
|
|
|
procedure TMainForm.btnNamedPipeStartClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if not Assigned(FNamedPipeObserver) then
|
|
|
|
begin
|
|
|
|
FNamedPipeObserver := TX2LogNamedPipeObserver.Create(edtPipeName.Text);
|
|
|
|
FLog.Attach(FNamedPipeObserver);
|
|
|
|
|
|
|
|
tsNamedPipe.ImageIndex := 1;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TMainForm.btnNamedPipeStopClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if Assigned(FNamedPipeObserver) then
|
|
|
|
begin
|
|
|
|
FLog.Detach(FNamedPipeObserver);
|
|
|
|
FNamedPipeObserver := nil;
|
|
|
|
|
|
|
|
tsNamedPipe.ImageIndex := 0;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2014-08-18 12:07:33 +00:00
|
|
|
|
|
|
|
procedure TMainForm.btnNamedPipeRefreshClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
server: TX2LogNamedPipeServerInfo;
|
|
|
|
|
|
|
|
begin
|
|
|
|
lbNamedPipeServers.Items.BeginUpdate;
|
|
|
|
try
|
|
|
|
lbNamedPipeServers.Items.Clear;
|
|
|
|
|
|
|
|
for server in TX2LogNamedPipeClient.ActiveServers do
|
|
|
|
lbNamedPipeServers.Items.Add(server.DisplayName + ' (' + server.PipeName + ')');
|
|
|
|
finally
|
|
|
|
lbNamedPipeServers.Items.EndUpdate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2014-10-22 18:24:54 +00:00
|
|
|
|
|
|
|
procedure TMainForm.btnTimerStartClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Timer.Interval := StrToIntDef(edtInterval.Text, 5) * 1000;
|
|
|
|
Timer.Enabled := True;
|
|
|
|
|
|
|
|
btnTimerStart.Enabled := False;
|
|
|
|
btnTimerStop.Enabled := True;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TMainForm.btnTimerStopClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Timer.Enabled := False;
|
|
|
|
|
|
|
|
btnTimerStart.Enabled := True;
|
|
|
|
btnTimerStop.Enabled := False;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TMainForm.TimerTimer(Sender: TObject);
|
|
|
|
begin
|
|
|
|
FLog.Warning('Batch start');
|
|
|
|
FLog.Info('Message 1');
|
|
|
|
FLog.Info('Message 2');
|
|
|
|
FLog.Info('Message 3');
|
|
|
|
end;
|
|
|
|
|
2016-10-14 15:02:27 +00:00
|
|
|
|
|
|
|
procedure TMainForm.btnValueTypesClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
FLog.InfoS('Testing the various value types',
|
|
|
|
['String', 'Hello world!',
|
2016-10-15 07:37:58 +00:00
|
|
|
'DateTime', LogDT,
|
2016-10-14 15:02:27 +00:00
|
|
|
'Has the large hadron collider destroyed the world yet?', False,
|
|
|
|
'Float', 3.1415,
|
|
|
|
'Integer', 89740987342]);
|
|
|
|
end;
|
|
|
|
|
2017-04-26 15:20:48 +00:00
|
|
|
|
|
|
|
procedure TMainForm.btnStructuredExceptionClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
try
|
|
|
|
raise Exception.Create('Stuff''s broken!');
|
|
|
|
except
|
|
|
|
on E:Exception do
|
|
|
|
FLog.ExceptionS(e, 'I totally expected that.', ['HasExtraInfo', False]);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2014-05-18 18:09:07 +00:00
|
|
|
end.
|