1
0
mirror of synced 2024-11-09 22:49:17 +00:00
x2log/NamedPipeClient/source/MainFrm.pas

53 lines
987 B
ObjectPascal
Raw Normal View History

2014-05-18 18:09:07 +00:00
unit MainFrm;
interface
uses
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
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
System.SysUtils,
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
FClient := TX2LogNamedPipeClient.Create('X2LogTest');
FObserver := TX2LogEventObserver.Create(DoLog);
FClient.Attach(FObserver);
2014-05-18 18:09:07 +00:00
end;
procedure TMainForm.DoLog(Sender: TObject; Level: TX2LogLevel; const Msg, Details: string);
2014-05-18 18:09:07 +00:00
begin
mmoLog.Lines.Add(DateTimeToStr(Now) + ' ' + GetLogLevelText(Level) + ': ' + Msg + ' (' + Details + ')');
2014-05-18 18:09:07 +00:00
end;
end.