1
0
mirror of synced 2024-11-12 15:49:16 +00:00
x2log/ServiceTest/source/ServiceDMU.pas
2014-05-26 17:20:27 +00:00

68 lines
1.2 KiB
ObjectPascal

unit ServiceDMU;
interface
uses
System.Classes,
System.SysUtils,
Vcl.Controls,
Vcl.Dialogs,
Vcl.ExtCtrls,
Vcl.Graphics,
Vcl.SvcMgr,
Winapi.Messages,
Winapi.Windows;
type
TServiceDM = class(TService)
tmrLog: TTimer;
procedure ServiceStart(Sender: TService; var Started: Boolean);
procedure tmrLogTimer(Sender: TObject);
public
function GetServiceController: TServiceController; override;
end;
var
ServiceDM: TServiceDM;
implementation
uses
X2Log.Intf,
X2Log.Global,
X2Log.Observer.NamedPipe;
{$R *.DFM}
procedure ServiceController(CtrlCode: DWord); stdcall;
begin
ServiceDM.Controller(CtrlCode);
end;
function TServiceDM.GetServiceController: TServiceController;
begin
Result := ServiceController;
end;
procedure TServiceDM.ServiceStart(Sender: TService; var Started: Boolean);
begin
TX2GlobalLog.Attach(TX2LogNamedPipeObserver.Create('X2LogService', X2LogLevelsAll));
end;
procedure TServiceDM.tmrLogTimer(Sender: TObject);
var
level: TX2LogLevel;
begin
level := TX2LogLevel(Random(Ord(High(TX2LogLevel))));
TX2GlobalLog.Log(level, 'Ping!');
end;
end.