2016-09-06 10:30:52 +02:00
|
|
|
program CustomLoggerSample;
|
|
|
|
|
|
|
|
{$APPTYPE CONSOLE}
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
System.SysUtils,
|
2016-11-27 23:17:20 +01:00
|
|
|
MVCFramework.Logger,
|
2017-06-01 14:46:10 +02:00
|
|
|
|
|
|
|
{$IFDEF MSWINDOWS}
|
|
|
|
|
2016-09-06 10:30:52 +02:00
|
|
|
Winapi.Windows,
|
|
|
|
Winapi.ShellAPI,
|
2017-06-01 14:46:10 +02:00
|
|
|
|
|
|
|
{$ENDIF}
|
|
|
|
|
2016-09-06 10:30:52 +02:00
|
|
|
Web.WebReq,
|
|
|
|
Web.WebBroker,
|
|
|
|
IdHTTPWebBrokerBridge,
|
|
|
|
MyControllerU in 'MyControllerU.pas',
|
2016-11-27 23:17:20 +01:00
|
|
|
WebModuleU in 'WebModuleU.pas' {MyWebModule: TWebModule} ,
|
|
|
|
CustomLoggerConfigU in 'CustomLoggerConfigU.pas';
|
2016-09-06 10:30:52 +02:00
|
|
|
|
|
|
|
{$R *.res}
|
|
|
|
|
|
|
|
procedure RunServer(APort: Integer);
|
|
|
|
var
|
|
|
|
LServer: TIdHTTPWebBrokerBridge;
|
|
|
|
begin
|
2020-02-26 13:10:41 +01:00
|
|
|
SetDefaultLogger(GetLogger); // setting the custom logger destinations
|
2016-11-27 23:17:20 +01:00
|
|
|
|
2016-09-06 10:30:52 +02:00
|
|
|
Writeln('** DMVCFramework Server **');
|
|
|
|
Writeln('WARNING! Run this program in debug and check the Delphi "Event" debug window to see the custom logs');
|
|
|
|
Writeln('WARNING! Also, the log file are generated in the custom path "MyFolder\MyLogs"');
|
|
|
|
Writeln(Format('Starting HTTP Server on port %d', [APort]));
|
|
|
|
LServer := TIdHTTPWebBrokerBridge.Create(nil);
|
|
|
|
try
|
|
|
|
LServer.DefaultPort := APort;
|
|
|
|
LServer.Active := True;
|
2017-06-01 14:46:10 +02:00
|
|
|
|
|
|
|
{$IFDEF MSWINDOWS}
|
|
|
|
|
2016-09-06 10:30:52 +02:00
|
|
|
ShellExecute(0, 'open', pChar('http://localhost:' + inttostr(APort)), nil, nil,
|
|
|
|
SW_SHOWMAXIMIZED);
|
2017-06-01 14:46:10 +02:00
|
|
|
|
|
|
|
{$ENDIF}
|
|
|
|
|
|
|
|
Writeln('Press RETURN to stop the server');
|
|
|
|
ReadLn;
|
2016-09-06 10:30:52 +02:00
|
|
|
finally
|
|
|
|
LServer.Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
begin
|
|
|
|
ReportMemoryLeaksOnShutdown := True;
|
|
|
|
try
|
|
|
|
if WebRequestHandler <> nil then
|
|
|
|
WebRequestHandler.WebModuleClass := WebModuleClass;
|
|
|
|
WebRequestHandlerProc.MaxConnections := 1024;
|
|
|
|
RunServer(8080);
|
|
|
|
except
|
|
|
|
on E: Exception do
|
|
|
|
Writeln(E.ClassName, ': ', E.Message);
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|