Skip to content

Commit

Permalink
Merge pull request #11 from Vitao-Jose/Vitao-Jose-patch-1
Browse files Browse the repository at this point in the history
Add files via upload
  • Loading branch information
viniciussanchez authored May 3, 2022
2 parents 22425b5 + 61cadc7 commit 82d1708
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Horse.Logger.Manager.pas
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ THorseLoggerManager = class(THorseLoggerThread)
class function GetProviderList: TList<IHorseLoggerProvider>;
class function ValidateValue(AValue: Integer): THorseLoggerLogItemNumber; overload;
class function ValidateValue(AValue: string): THorseLoggerLogItemString; overload;
class function ValidateValue(AValue: TDateTime): THorseLoggerLogItemString; overload;
// Incluido parametro AShort : Boolean - 2022-02-12
class function ValidateValue(AValue: TDateTime; AShort : Boolean): THorseLoggerLogItemString; overload;
class function GetDefaultManager: THorseLoggerManager; static;
public
{ public declarations }
Expand Down Expand Up @@ -66,7 +67,10 @@ procedure DefaultHorseCallback(AReq: THorseRequest; ARes: THorseResponse; ANext:
LMilliSecondsBetween := MilliSecondsBetween(LAfterDateTime, LBeforeDateTime);
LLog := THorseLoggerLog.Create;
try
LLog.{$IFDEF FPC}Add{$ELSE}AddPair{$ENDIF}('time', THorseLoggerManager.ValidateValue(LBeforeDateTime));
// Incluido valor FALSE para parametro AShort - 2022-02-12
LLog.{$IFDEF FPC}Add{$ELSE}AddPair{$ENDIF}('time', THorseLoggerManager.ValidateValue(LBeforeDateTime, false));
// Incluido opcao 'time_short' - 2022-02-12
LLog.{$IFDEF FPC}Add{$ELSE}AddPair{$ENDIF}('time_short', THorseLoggerManager.ValidateValue(LBeforeDateTime, true));
LLog.{$IFDEF FPC}Add{$ELSE}AddPair{$ENDIF}('execution_time', THorseLoggerManager.ValidateValue(LMilliSecondsBetween.ToString));
LLog.{$IFDEF FPC}Add{$ELSE}AddPair{$ENDIF}('request_clientip', THorseLoggerManager.ValidateValue(ClientIP(AReq)));
LLog.{$IFDEF FPC}Add{$ELSE}AddPair{$ENDIF}('request_method', THorseLoggerManager.ValidateValue(AReq.RawWebRequest.Method));
Expand Down Expand Up @@ -188,9 +192,12 @@ class function THorseLoggerManager.ValidateValue(AValue: string): THorseLoggerLo
Result := THorseLoggerLogItemString.Create(AValue);
end;

class function THorseLoggerManager.ValidateValue(AValue: TDateTime): THorseLoggerLogItemString;
class function THorseLoggerManager.ValidateValue(AValue: TDateTime; AShort : Boolean): THorseLoggerLogItemString;
begin
Result := THorseLoggerLogItemString.Create(FormatDateTime('dd/MMMM/yyyy hh:mm:ss.zzz', AValue));
if (AShort) then
Result := THorseLoggerLogItemString.Create(FormatDateTime('dd/mm/yyyy hh:mm:ss.zzz', AValue))
else
Result := THorseLoggerLogItemString.Create(FormatDateTime('dd/MMMM/yyyy hh:mm:ss.zzz', AValue));
end;

end.

0 comments on commit 82d1708

Please sign in to comment.