diff --git a/HorseLogger.dproj b/HorseLogger.dproj
index 388ff9b..19390be 100644
--- a/HorseLogger.dproj
+++ b/HorseLogger.dproj
@@ -87,7 +87,7 @@
System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)
All
HorseLogger
- $(DCC_UnitSearchPath);modules\.dcp;modules\.dcu;modules;modules\horse\src
+ $(DCC_UnitSearchPath);modules\.dcp;modules\.dcu;modules;modules\horse\src;modules\horse-utils-clientip\src
None
diff --git a/boss-lock.json b/boss-lock.json
index 517427c..e7b7189 100644
--- a/boss-lock.json
+++ b/boss-lock.json
@@ -2,10 +2,18 @@
"hash": "d41d8cd98f00b204e9800998ecf8427e",
"updated": "2020-06-03T10:22:23.5303461-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.1",
- "hash": "a9e80dbc40536b989ad1089a85bb1c5b",
+ "version": "v2.0.6",
+ "hash": "cca1769dfab681cfd26ae8499f9045e1",
"artifacts": {},
"failed": false,
"changed": false
diff --git a/boss.json b/boss.json
index c72e87b..fad2cbe 100644
--- a/boss.json
+++ b/boss.json
@@ -2,10 +2,11 @@
"name": "horse-logger",
"description": "Middleware for access logging in HORSE",
"version": "1.0.0",
- "homepage": "",
- "mainsrc": "src/",
+ "homepage": "https://github.com/HashLoad/horse-logger",
+ "mainsrc": "./src/",
"projects": [],
"dependencies": {
- "github.com/HashLoad/horse": "^2.0.0"
+ "github.com/dliocode/horse-utils-clientip": "^0.0.5",
+ "github.com/hashload/horse": "^v2.0.6"
}
}
\ No newline at end of file
diff --git a/samples/boss-lock.json b/samples/boss-lock.json
index cbbdb8e..b352686 100644
--- a/samples/boss-lock.json
+++ b/samples/boss-lock.json
@@ -1,11 +1,11 @@
{
"hash": "d41d8cd98f00b204e9800998ecf8427e",
- "updated": "2020-06-03T10:54:14.0172469-03:00",
+ "updated": "2020-12-24T12:33:51.3353566-03:00",
"installedModules": {
"github.com/hashload/horse": {
"name": "horse",
- "version": "v2.0.1",
- "hash": "a9e80dbc40536b989ad1089a85bb1c5b",
+ "version": "v2.0.6",
+ "hash": "cca1769dfab681cfd26ae8499f9045e1",
"artifacts": {},
"failed": false,
"changed": false
@@ -13,7 +13,7 @@
"github.com/hashload/horse-logger": {
"name": "horse-logger",
"version": "0.1.5",
- "hash": "e8ce2dba3388af18152bf456394c98b6",
+ "hash": "0621e32582c643397c3b3c48aeffe33b",
"artifacts": {},
"failed": false,
"changed": false
diff --git a/samples/boss.json b/samples/boss.json
index df2f028..2daef55 100644
--- a/samples/boss.json
+++ b/samples/boss.json
@@ -6,7 +6,6 @@
"mainsrc": "./",
"projects": [],
"dependencies": {
- "github.com/hashload/horse": "^2.0.0",
"github.com/hashload/horse-logger": "^0.1.0"
}
}
\ No newline at end of file
diff --git a/samples/samples.dproj b/samples/samples.dproj
index 1ce5289..93b5c90 100644
--- a/samples/samples.dproj
+++ b/samples/samples.dproj
@@ -23,11 +23,6 @@
Base
true
-
- true
- Base
- true
-
true
Base
@@ -112,9 +107,6 @@
$(BDS)\bin\Artwork\Android\FM_NotificationIcon_96x96.png
android-support-v4.dex.jar;cloud-messaging.dex.jar;com-google-android-gms.play-services-ads-base.17.2.0.dex.jar;com-google-android-gms.play-services-ads-identifier.16.0.0.dex.jar;com-google-android-gms.play-services-ads-lite.17.2.0.dex.jar;com-google-android-gms.play-services-ads.17.2.0.dex.jar;com-google-android-gms.play-services-analytics-impl.16.0.8.dex.jar;com-google-android-gms.play-services-analytics.16.0.8.dex.jar;com-google-android-gms.play-services-base.16.0.1.dex.jar;com-google-android-gms.play-services-basement.16.2.0.dex.jar;com-google-android-gms.play-services-gass.17.2.0.dex.jar;com-google-android-gms.play-services-identity.16.0.0.dex.jar;com-google-android-gms.play-services-maps.16.1.0.dex.jar;com-google-android-gms.play-services-measurement-base.16.4.0.dex.jar;com-google-android-gms.play-services-measurement-sdk-api.16.4.0.dex.jar;com-google-android-gms.play-services-stats.16.0.1.dex.jar;com-google-android-gms.play-services-tagmanager-v4-impl.16.0.8.dex.jar;com-google-android-gms.play-services-tasks.16.0.1.dex.jar;com-google-android-gms.play-services-wallet.16.0.1.dex.jar;com-google-firebase.firebase-analytics.16.4.0.dex.jar;com-google-firebase.firebase-common.16.1.0.dex.jar;com-google-firebase.firebase-iid-interop.16.0.1.dex.jar;com-google-firebase.firebase-iid.17.1.1.dex.jar;com-google-firebase.firebase-measurement-connector.17.0.1.dex.jar;com-google-firebase.firebase-messaging.17.5.0.dex.jar;fmx.dex.jar;google-play-billing.dex.jar;google-play-licensing.dex.jar
-
- DBXSqliteDriver;RESTComponents;fmxase;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)
-
DBXSqliteDriver;RESTComponents;fmxase;DBXInterBaseDriver;emsclientfiredac;tethering;DataSnapFireDAC;PackageAspectKeyboard;bindcompfmx;fmx;FireDACIBDriver;DockingFormCommandLine;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)
@@ -592,6 +584,32 @@
0
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
1
@@ -691,6 +709,16 @@
1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset
+ 1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset
+ 1
+
+
1
@@ -702,6 +730,66 @@
1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset
+ 1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset
+ 1
+
+
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
1
@@ -801,6 +889,16 @@
1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset
+ 1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset
+ 1
+
+
1
@@ -812,6 +910,16 @@
1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset
+ 1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset
+ 1
+
+
1
@@ -856,6 +964,86 @@
1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset
+ 1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset
+ 1
+
+
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset
+ 1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset
+ 1
+
+
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
+ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset
+ 1
+
+
1
@@ -903,6 +1091,16 @@
1
+
+
+ ..\$(PROJECTNAME).launchscreen
+ 64
+
+
+ ..\$(PROJECTNAME).launchscreen
+ 64
+
+
1
@@ -1031,7 +1229,6 @@
False
False
- False
False
False
True
diff --git a/src/Horse.Logger.pas b/src/Horse.Logger.pas
index 59f29cc..28b06f6 100644
--- a/src/Horse.Logger.pas
+++ b/src/Horse.Logger.pas
@@ -6,13 +6,13 @@
interface
uses
- Horse, Horse.HTTP
+
{$IFDEF FPC }
- , SysUtils, Classes, SyncObjs, Generics.Collections
+ SysUtils, Classes, SyncObjs, Generics.Collections,
{$ELSE}
- , System.SysUtils, System.SyncObjs, , System.Classes, System.Generics.Collections
+ System.SysUtils, System.SyncObjs, System.Classes, System.Generics.Collections,
{$ENDIF}
- ;
+ Horse, Horse.HTTP, Horse.Utils.ClientIP;
type
{ THorseLoggerConfig }
THorseLoggerConfig = class
@@ -89,6 +89,7 @@ procedure Middleware(ARequest: THorseRequest; AResponse: THorseResponse; ANext:
LLog := THorseLogger.GetDefault.FHorseLoggerConfig.LogFormat;
LLog := LLog.Replace('${time}', THorseLogger.ValidateValue(LBeforeDateTime));
LLog := LLog.Replace('${execution_time}', THorseLogger.ValidateValue(LMilliSecondsBetween));
+ LLog := LLog.Replace('${request_clientip}', THorseLogger.ValidateValue(ClientIP(ARequest)));
LLog := LLog.Replace('${request_method}', THorseLogger.ValidateValue(LWebRequest.Method));
LLog := LLog.Replace('${request_version}', THorseLogger.ValidateValue(LWebRequest.ProtocolVersion));
LLog := LLog.Replace('${request_url}', THorseLogger.ValidateValue(LWebRequest.URL));
@@ -119,15 +120,15 @@ procedure Middleware(ARequest: THorseRequest; AResponse: THorseResponse; ANext:
LLog := LLog.Replace('${response_content_length}', THorseLogger.ValidateValue(LWebResponse.ContentLength));
LLog := LLog.Replace('${response_status}', THorseLogger.ValidateValue(LWebResponse.{$IF DEFINED(FPC)}Code.ToString(){$ELSE}StatusCode{$ENDIF}));
{$IF NOT DEFINED(FPC)}
- LLog := LLog.Replace('${request_derived_from}', ValidateValue(LWebRequest.DerivedFrom));
- LLog := LLog.Replace('${request_remote_ip}', ValidateValue(LWebRequest. RemoteIP));
- LLog := LLog.Replace('${request_internal_path_info}', ValidateValue(LWebRequest.InternalPathInfo));
- LLog := LLog.Replace('${request_raw_path_info}', ValidateValue(LWebRequest.RawPathInfo));
- LLog := LLog.Replace('${request_cache_control}', ValidateValue(LWebRequest.CacheControl));
- LLog := LLog.Replace('${response_realm}', ValidateValue(LWebResponse.Realm));
- LLog := LLog.Replace('${response_log_message}', ValidateValue(LWebResponse.LogMessage));
- LLog := LLog.Replace('${response_title}', ValidateValue(LWebResponse.Title));
- LLog := LLog.Replace('${response_content_version}', ValidateValue(LWebResponse.ContentVersion));
+ LLog := LLog.Replace('${request_derived_from}', THorseLogger.ValidateValue(LWebRequest.DerivedFrom));
+ LLog := LLog.Replace('${request_remote_ip}', THorseLogger.ValidateValue(LWebRequest. RemoteIP));
+ LLog := LLog.Replace('${request_internal_path_info}', THorseLogger.ValidateValue(LWebRequest.InternalPathInfo));
+ LLog := LLog.Replace('${request_raw_path_info}', THorseLogger.ValidateValue(LWebRequest.RawPathInfo));
+ LLog := LLog.Replace('${request_cache_control}', THorseLogger.ValidateValue(LWebRequest.CacheControl));
+ LLog := LLog.Replace('${response_realm}', THorseLogger.ValidateValue(LWebResponse.Realm));
+ LLog := LLog.Replace('${response_log_message}', THorseLogger.ValidateValue(LWebResponse.LogMessage));
+ LLog := LLog.Replace('${response_title}', THorseLogger.ValidateValue(LWebResponse.Title));
+ LLog := LLog.Replace('${response_content_version}', THorseLogger.ValidateValue(LWebResponse.ContentVersion));
{$ENDIF}
THorseLogger.GetDefault.NewLog(LLog);
end;