diff --git a/samples/boss-lock.json b/samples/boss-lock.json
index b352686..0307f06 100644
--- a/samples/boss-lock.json
+++ b/samples/boss-lock.json
@@ -1,7 +1,15 @@
{
"hash": "d41d8cd98f00b204e9800998ecf8427e",
- "updated": "2020-12-24T12:33:51.3353566-03:00",
+ "updated": "2020-12-24T12:56:26.8645864-03:00",
"installedModules": {
+ "github.com/dliocode/horse-utils-clientip": {
+ "name": "horse-utils-clientip",
+ "version": "0.0.5",
+ "hash": "e70e774b0e0e7248d1e9028fc9c4542e",
+ "artifacts": {},
+ "failed": false,
+ "changed": false
+ },
"github.com/hashload/horse": {
"name": "horse",
"version": "v2.0.6",
@@ -12,8 +20,8 @@
},
"github.com/hashload/horse-logger": {
"name": "horse-logger",
- "version": "0.1.5",
- "hash": "0621e32582c643397c3b3c48aeffe33b",
+ "version": "1.0.1",
+ "hash": "327d195902f59abb5c093e2791c8d0b2",
"artifacts": {},
"failed": false,
"changed": false
diff --git a/samples/boss.json b/samples/boss.json
index 2daef55..ea56582 100644
--- a/samples/boss.json
+++ b/samples/boss.json
@@ -6,6 +6,6 @@
"mainsrc": "./",
"projects": [],
"dependencies": {
- "github.com/hashload/horse-logger": "^0.1.0"
+ "github.com/hashload/horse-logger": "^1.0.1"
}
}
\ No newline at end of file
diff --git a/samples/samples.dproj b/samples/samples.dproj
index 93b5c90..7a33b3a 100644
--- a/samples/samples.dproj
+++ b/samples/samples.dproj
@@ -69,7 +69,7 @@
false
System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)
samples
- modules\.dcp;modules\.dcu;modules;modules\horse\src;modules\horse-logger\src;$(DCC_UnitSearchPath)
+ modules\.dcp;modules\.dcu;modules;modules\horse\src;modules\horse-logger\src;modules\horse-utils-clientip\src;$(DCC_UnitSearchPath)
DBXSqliteDriver;RESTComponents;DBXInterBaseDriver;emsclientfiredac;tethering;DataSnapFireDAC;PackageAspectKeyboard;bindcompfmx;fmx;FireDACIBDriver;FireDACDBXDriver;dbexpress;IndyCore;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;soapserver;bindengine;CloudService;FireDACCommonDriver;DataSnapClient;inet;IndyIPCommon;bindcompdbx;IndyIPServer;IndySystem;fmxFireDAC;FireDAC;FireDACSqliteDriver;soaprtl;DbxCommonDriver;xmlrtl;soapmidas;DataSnapNativeClient;FireDACDSDriver;rtl;DbxClientDriver;CustomIPTransport;bindcomp;IndyIPClient;dbxcds;dsnapxml;DataSnapProviderClient;dbrtl;IndyProtocols;$(DCC_UsePackage)
diff --git a/src/Horse.Logger.pas b/src/Horse.Logger.pas
index 28b06f6..ba3390c 100644
--- a/src/Horse.Logger.pas
+++ b/src/Horse.Logger.pas
@@ -36,7 +36,6 @@ THorseLogger = class(TThread)
class function ValidateValue(AValue: Integer): string; overload;
class function ValidateValue(AValue: string): string; overload;
class function ValidateValue(AValue: TDateTime): string; overload;
- class function BuildLogger: THorseCallback;
class function GetDefaultHorseLogger: THorseLogger;
public
procedure AfterConstruction; override;
@@ -47,12 +46,11 @@ THorseLogger = class(TThread)
class function GetDefault: THorseLogger;
class function New(AConfig: THorseLoggerConfig): THorseCallback; overload;
class function New: THorseCallback; overload;
- class property HorseLoggerConfig : THorseLoggerConfig read FHorseLoggerConfig write FHorseLoggerConfig;
end;
const
DEFAULT_HORSE_LOG_FORMAT =
- '${request_remote_addr} [${time}] ${request_user_agent}'+
+ '${request_clientip} [${time}] ${request_user_agent}'+
' "${request_method} ${request_path_info} ${request_version}"'+
' ${response_status} ${response_content_length}';
@@ -83,8 +81,8 @@ procedure Middleware(ARequest: THorseRequest; AResponse: THorseResponse; ANext:
LAfterDateTime := Now();
LMilliSecondsBetween := MilliSecondsBetween(LAfterDateTime, LBeforeDateTime);
- LWebRequest := THorseHackRequest(ARequest).GetWebRequest;
- LWebResponse := THorseHackResponse(AResponse).GetWebResponse;
+ LWebRequest := THorseHackRequest(ARequest).RawWebRequest;
+ LWebResponse := THorseHackResponse(AResponse).RawWebResponse;
LLog := THorseLogger.GetDefault.FHorseLoggerConfig.LogFormat;
LLog := LLog.Replace('${time}', THorseLogger.ValidateValue(LBeforeDateTime));
@@ -161,11 +159,6 @@ procedure THorseLogger.BeforeDestruction;
FreeInternalInstances;
end;
-class function THorseLogger.BuildLogger: THorseCallback;
-begin
- Result := @Middleware;
-end;
-
procedure THorseLogger.Execute;
var
LWait: TWaitResult;
@@ -227,7 +220,7 @@ procedure THorseLogger.FreeInternalInstances;
class function THorseLogger.New(AConfig: THorseLoggerConfig): THorseCallback;
begin
Self.FHorseLoggerConfig := AConfig;
- Result := Middleware();
+ Result := Middleware;
end;
class function THorseLogger.New: THorseCallback;
@@ -283,6 +276,8 @@ procedure THorseLogger.SaveLogCache;
class destructor THorseLogger.UnInitialize;
begin
+ if Assigned(FHorseLoggerConfig) then
+ FreeAndNil(FHorseLoggerConfig);
if Assigned(FHorseLogger) then
begin
FHorseLogger.Terminate;
@@ -308,4 +303,4 @@ class function THorseLogger.ValidateValue(AValue: Integer): string;
Result := AValue.ToString;
end;
-end.
+end.
\ No newline at end of file