2014-05-18 18:09:07 +00:00
|
|
|
unit MainFrm;
|
|
|
|
|
|
|
|
interface
|
|
|
|
uses
|
2014-05-25 14:20:58 +00:00
|
|
|
System.Classes,
|
|
|
|
Vcl.Controls,
|
|
|
|
Vcl.Forms,
|
|
|
|
Vcl.StdCtrls,
|
|
|
|
|
|
|
|
X2Log.Intf;
|
2014-05-18 18:09:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
TMainForm = class(TForm)
|
|
|
|
mmoLog: TMemo;
|
|
|
|
|
|
|
|
procedure FormCreate(Sender: TObject);
|
|
|
|
private
|
2014-05-25 14:20:58 +00:00
|
|
|
FClient: IX2LogObservable;
|
|
|
|
FObserver: IX2LogObserver;
|
|
|
|
protected
|
|
|
|
procedure DoLog(Sender: TObject; Level: TX2LogLevel; const Msg, Details: string);
|
2014-05-18 18:09:07 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
2014-05-26 17:20:27 +00:00
|
|
|
System.SysUtils,
|
|
|
|
|
2014-05-25 14:20:58 +00:00
|
|
|
X2Log.Constants,
|
|
|
|
X2Log.Client.NamedPipe,
|
|
|
|
X2Log.Observer.Event;
|
2014-05-18 18:09:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
|
|
{ TMainForm }
|
|
|
|
procedure TMainForm.FormCreate(Sender: TObject);
|
|
|
|
begin
|
2014-05-25 14:20:58 +00:00
|
|
|
FClient := TX2LogNamedPipeClient.Create('X2LogTest');
|
|
|
|
FObserver := TX2LogEventObserver.Create(DoLog);
|
|
|
|
FClient.Attach(FObserver);
|
2014-05-18 18:09:07 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-25 14:20:58 +00:00
|
|
|
procedure TMainForm.DoLog(Sender: TObject; Level: TX2LogLevel; const Msg, Details: string);
|
2014-05-18 18:09:07 +00:00
|
|
|
begin
|
2014-05-26 17:20:27 +00:00
|
|
|
mmoLog.Lines.Add(DateTimeToStr(Now) + ' ' + GetLogLevelText(Level) + ': ' + Msg + ' (' + Details + ')');
|
2014-05-18 18:09:07 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|