Added TLogWriterDecorator; removed deprecated *fmt methods from ILogWriter

This commit is contained in:
Daniele Teti 2024-09-03 12:57:27 +02:00
parent 0c80ec022d
commit fe555912a5
6 changed files with 254 additions and 84 deletions

View File

@ -39,6 +39,47 @@ type
class function Build(Appender: ILogAppender; Filter: TFunc<TLogItem, boolean>): ILogAppender;
end;
TLogWriterPredicate = reference to function (const aType: TLogType; const aMessage, aTag: string): Boolean;
TLogWriterDecorator = class(TInterfacedObject, ILogWriter)
private
fDecoratedLogWriter: ILogWriter;
fFilter: TLogWriterPredicate;
protected
{ ILogWriter }
procedure Debug(const aMessage: string; const aTag: string); overload;
procedure Debug(const aMessage: string; const aParams: array of TVarRec; const aTag: string); overload;
procedure Info(const aMessage: string; const aTag: string); overload;
procedure Info(const aMessage: string; const aParams: array of TVarRec; const aTag: string); overload;
procedure Warn(const aMessage: string; const aTag: string); overload;
procedure Warn(const aMessage: string; const aParams: array of TVarRec; const aTag: string); overload;
procedure Error(const aMessage: string; const aTag: string); overload;
procedure Error(const aMessage: string; const aParams: array of TVarRec; const aTag: string); overload;
procedure Fatal(const aMessage: string; const aTag: string); overload;
procedure Fatal(const aMessage: string; const aParams: array of TVarRec; const aTag: string); overload;
procedure Log(const aType: TLogType; const aMessage: string; const aTag: string); overload;
procedure Log(const aType: TLogType; const aMessage: string; const aParams: array of const; const aTag: string); overload;
{ ICustomLogWriter}
function GetAppendersClassNames: TArray<string>;
function GetAppenders(const aIndex: Integer): ILogAppender;
property Appenders[const aIndex: Integer]: ILogAppender read GetAppenders;
procedure AddAppender(const aAppender: ILogAppender);
procedure DelAppender(const aAppender: ILogAppender);
function AppendersCount(): Integer;
///
constructor Create(LogWriter: ILogWriter; Filter: TLogWriterPredicate);
public
class function Build(LogWriter: ILogWriter; Filter: TLogWriterPredicate): ILogWriter;
end;
implementation
@ -91,7 +132,114 @@ end;
class function TLoggerProFilter.Build(Appender: ILogAppender;
Filter: TFunc<TLogItem, boolean>): ILogAppender;
begin
result := TLoggerProAppenderFilterImpl.Create(Appender, Filter);
Result := TLoggerProAppenderFilterImpl.Create(Appender, Filter);
end;
{ TLogWriterDecorator }
class function TLogWriterDecorator.Build(LogWriter: ILogWriter;
Filter: TLogWriterPredicate): ILogWriter;
begin
Result := TLogWriterDecorator.Create(LogWriter, Filter);
end;
constructor TLogWriterDecorator.Create(LogWriter: ILogWriter; Filter: TLogWriterPredicate);
begin
inherited Create;
fDecoratedLogWriter := LogWriter;
fFilter := Filter;
end;
procedure TLogWriterDecorator.AddAppender(const aAppender: ILogAppender);
begin
fDecoratedLogWriter.AddAppender(aAppender);
end;
function TLogWriterDecorator.AppendersCount: Integer;
begin
Result := fDecoratedLogWriter.AppendersCount;
end;
function TLogWriterDecorator.GetAppenders(const aIndex: Integer): ILogAppender;
begin
Result := fDecoratedLogWriter.GetAppenders(aIndex);
end;
function TLogWriterDecorator.GetAppendersClassNames: TArray<string>;
begin
Result := fDecoratedLogWriter.GetAppendersClassNames;
end;
// ILogWriter
procedure TLogWriterDecorator.Debug(const aMessage, aTag: string);
begin
Log(TLogType.Debug, aMessage, aTag);
end;
procedure TLogWriterDecorator.Debug(const aMessage: string; const aParams: array of TVarRec; const aTag: string);
begin
Log(TLogType.Debug, aMessage, aParams, aTag);
end;
procedure TLogWriterDecorator.DelAppender(const aAppender: ILogAppender);
begin
fDecoratedLogWriter.DelAppender(aAppender);
end;
procedure TLogWriterDecorator.Error(const aMessage, aTag: string);
begin
Log(TLogType.Error, aMessage, aTag);
end;
procedure TLogWriterDecorator.Error(const aMessage: string; const aParams: array of TVarRec; const aTag: string);
begin
Log(TLogType.Error, aMessage, aParams, aTag);
end;
procedure TLogWriterDecorator.Fatal(const aMessage, aTag: string);
begin
Log(TLogType.Fatal, aMessage, aTag);
end;
procedure TLogWriterDecorator.Fatal(const aMessage: string;
const aParams: array of TVarRec; const aTag: string);
begin
Log(TLogType.Fatal, aMessage, aParams, aTag);
end;
procedure TLogWriterDecorator.Info(const aMessage, aTag: string);
begin
Log(TLogType.Info, aMessage, aTag);
end;
procedure TLogWriterDecorator.Info(const aMessage: string; const aParams: array of TVarRec; const aTag: string);
begin
Log(TLogType.Info, aMessage, aParams, aTag);
end;
procedure TLogWriterDecorator.Log(const aType: TLogType; const aMessage, aTag: string);
begin
if fFilter(aType, aMessage, aTag) then
begin
fDecoratedLogWriter.Log(aType, aMessage, aTag);
end;
end;
procedure TLogWriterDecorator.Log(const aType: TLogType; const aMessage: string; const aParams: array of const; const aTag: string);
begin
Log(aType, Format(aMessage, aParams), aTag);
end;
procedure TLogWriterDecorator.Warn(const aMessage, aTag: string);
begin
Log(TLogType.Warning, aMessage, aTag);
end;
procedure TLogWriterDecorator.Warn(const aMessage: string; const aParams: array of TVarRec; const aTag: string);
begin
Log(TLogType.Warning, aMessage, aParams, aTag);
end;

View File

@ -153,27 +153,21 @@ type
['{A717A040-4493-458F-91B2-6F6E2AFB496F}']
procedure Debug(const aMessage: string; const aTag: string); overload;
procedure Debug(const aMessage: string; const aParams: array of TVarRec; const aTag: string); overload;
procedure DebugFmt(const aMessage: string; const aParams: array of TVarRec; const aTag: string); deprecated;
procedure Info(const aMessage: string; const aTag: string); overload;
procedure Info(const aMessage: string; const aParams: array of TVarRec; const aTag: string); overload;
procedure InfoFmt(const aMessage: string; const aParams: array of TVarRec; const aTag: string); deprecated;
procedure Warn(const aMessage: string; const aTag: string); overload;
procedure Warn(const aMessage: string; const aParams: array of TVarRec; const aTag: string); overload;
procedure WarnFmt(const aMessage: string; const aParams: array of TVarRec; const aTag: string); deprecated;
procedure Error(const aMessage: string; const aTag: string); overload;
procedure Error(const aMessage: string; const aParams: array of TVarRec; const aTag: string); overload;
procedure ErrorFmt(const aMessage: string; const aParams: array of TVarRec; const aTag: string); deprecated;
procedure Fatal(const aMessage: string; const aTag: string); overload;
procedure Fatal(const aMessage: string; const aParams: array of TVarRec; const aTag: string); overload;
procedure FatalFmt(const aMessage: string; const aParams: array of TVarRec; const aTag: string); deprecated;
procedure Log(const aType: TLogType; const aMessage: string; const aTag: string); overload;
procedure Log(const aType: TLogType; const aMessage: string; const aParams: array of const; const aTag: string); overload;
procedure LogFmt(const aType: TLogType; const aMessage: string; const aParams: array of const; const aTag: string); deprecated;
end;
TLogAppenderList = TList<ILogAppender>;
@ -268,27 +262,20 @@ type
public
procedure Debug(const aMessage: string; const aTag: string); overload;
procedure Debug(const aMessage: string; const aParams: array of TVarRec; const aTag: string); overload;
procedure DebugFmt(const aMessage: string; const aParams: array of TVarRec; const aTag: string);
procedure Info(const aMessage: string; const aTag: string); overload;
procedure Info(const aMessage: string; const aParams: array of TVarRec; const aTag: string); overload;
procedure InfoFmt(const aMessage: string; const aParams: array of TVarRec; const aTag: string);
procedure Warn(const aMessage: string; const aTag: string); overload;
procedure Warn(const aMessage: string; const aParams: array of TVarRec; const aTag: string); overload;
procedure WarnFmt(const aMessage: string; const aParams: array of TVarRec; const aTag: string);
procedure Error(const aMessage: string; const aTag: string); overload;
procedure Error(const aMessage: string; const aParams: array of TVarRec; const aTag: string); overload;
procedure ErrorFmt(const aMessage: string; const aParams: array of TVarRec; const aTag: string);
procedure Fatal(const aMessage: string; const aTag: string); overload;
procedure Fatal(const aMessage: string; const aParams: array of TVarRec; const aTag: string); overload;
procedure FatalFmt(const aMessage: string; const aParams: array of TVarRec; const aTag: string);
procedure Log(const aType: TLogType; const aMessage: string; const aParams: array of const; const aTag: string); overload;
procedure LogFmt(const aType: TLogType; const aMessage: string; const aParams: array of const; const aTag: string);
end;
TOnAppenderLogRow = reference to procedure(const LogItem: TLogItem; out LogRow: string);
@ -640,11 +627,6 @@ begin
Log(TLogType.Debug, aMessage, aParams, aTag);
end;
procedure TLogWriter.DebugFmt(const aMessage: string; const aParams: array of TVarRec; const aTag: string);
begin
Debug(aMessage, aParams, aTag);
end;
procedure TLogWriter.Error(const aMessage, aTag: string);
begin
Log(TLogType.Error, aMessage, aTag);
@ -655,11 +637,6 @@ begin
Log(TLogType.Error, aMessage, aParams, aTag);
end;
procedure TLogWriter.ErrorFmt(const aMessage: string; const aParams: array of TVarRec; const aTag: string);
begin
Error(aMessage, aParams, aTag);
end;
procedure TLogWriter.Fatal(const aMessage, aTag: string);
begin
Log(TLogType.Fatal, aMessage, aTag);
@ -671,12 +648,6 @@ begin
Log(TLogType.Fatal, aMessage, aParams, aTag);
end;
procedure TLogWriter.FatalFmt(const aMessage: string;
const aParams: array of TVarRec; const aTag: string);
begin
Fatal(aMessage, aParams, aTag);
end;
procedure TLogWriter.Info(const aMessage, aTag: string);
begin
Log(TLogType.Info, aMessage, aTag);
@ -687,22 +658,11 @@ begin
Log(TLogType.Info, aMessage, aParams, aTag);
end;
procedure TLogWriter.InfoFmt(const aMessage: string; const aParams: array of TVarRec; const aTag: string);
begin
Info(aMessage, aParams, aTag);
end;
procedure TLogWriter.Log(const aType: TLogType; const aMessage: string; const aParams: array of const; const aTag: string);
begin
Log(aType, Format(aMessage, aParams), aTag);
end;
procedure TLogWriter.LogFmt(const aType: TLogType; const aMessage: string; const aParams: array of const; const aTag: string);
begin
Log(aType, aMessage, aParams, aTag);
end;
procedure TLogWriter.Warn(const aMessage, aTag: string);
begin
Log(TLogType.Warning, aMessage, aTag);
@ -713,11 +673,6 @@ begin
Log(TLogType.Warning, aMessage, aParams, aTag);
end;
procedure TLogWriter.WarnFmt(const aMessage: string; const aParams: array of TVarRec; const aTag: string);
begin
Warn(aMessage, aParams, aTag);
end;
{ TLogger.TLogItem }
function TLogItem.Clone: TLogItem;

View File

@ -6,6 +6,7 @@ program CustomLoggerSample;
uses
System.SysUtils,
MVCFramework.Logger,
LoggerPro.Proxy,
{$IFDEF MSWINDOWS}
@ -19,7 +20,7 @@ uses
IdHTTPWebBrokerBridge,
MyControllerU in 'MyControllerU.pas',
WebModuleU in 'WebModuleU.pas' {MyWebModule: TWebModule} ,
CustomLoggerConfigU in 'CustomLoggerConfigU.pas';
CustomLoggerConfigU in 'CustomLoggerConfigU.pas', LoggerPro;
{$R *.res}
@ -51,7 +52,24 @@ begin
end;
begin
SetDefaultLogger(GetLogger);
//Option 1
//You can customize the logger providing a complete new one
//SetDefaultLogger(GetLogger);
//Option 2
//If you want to sligthly change the behaviour of the default logger
//you can retrive the "default configuration" and then apply a decorator
//with a filter function which "decides" if the logitem must be go through
//the appenders chain or not (so, discarded)
SetDefaultLogger(TLogWriterDecorator.Build(CreateLoggerWithDefaultConfiguration,
function (const aType: TLogType; const aMessage, aTag: string): Boolean
begin
Result := True;
end));
ReportMemoryLeaksOnShutdown := True;
try
if WebRequestHandler <> nil then

View File

@ -24,6 +24,26 @@
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='iOSDevice64' and '$(Base)'=='true') or '$(Base_iOSDevice64)'!=''">
<Base_iOSDevice64>true</Base_iOSDevice64>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='iOSSimARM64' and '$(Base)'=='true') or '$(Base_iOSSimARM64)'!=''">
<Base_iOSSimARM64>true</Base_iOSSimARM64>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='OSX64' and '$(Base)'=='true') or '$(Base_OSX64)'!=''">
<Base_OSX64>true</Base_OSX64>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='OSXARM64' and '$(Base)'=='true') or '$(Base_OSXARM64)'!=''">
<Base_OSXARM64>true</Base_OSXARM64>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Base)'=='true') or '$(Base_Win32)'!=''">
<Base_Win32>true</Base_Win32>
<CfgParent>Base</CfgParent>
@ -80,6 +100,26 @@
<BT_BuildType>Debug</BT_BuildType>
<EnabledSysJars>activity-1.1.0.dex.jar;annotation-1.2.0.dex.jar;appcompat-1.2.0.dex.jar;appcompat-resources-1.2.0.dex.jar;asynclayoutinflater-1.0.0.dex.jar;billing-4.0.0.dex.jar;biometric-1.1.0.dex.jar;browser-1.0.0.dex.jar;cloud-messaging.dex.jar;collection-1.1.0.dex.jar;coordinatorlayout-1.0.0.dex.jar;core-1.5.0-rc02.dex.jar;core-common-2.1.0.dex.jar;core-runtime-2.1.0.dex.jar;cursoradapter-1.0.0.dex.jar;customview-1.0.0.dex.jar;documentfile-1.0.0.dex.jar;drawerlayout-1.0.0.dex.jar;firebase-annotations-16.0.0.dex.jar;firebase-common-20.0.0.dex.jar;firebase-components-17.0.0.dex.jar;firebase-datatransport-18.0.0.dex.jar;firebase-encoders-17.0.0.dex.jar;firebase-encoders-json-18.0.0.dex.jar;firebase-iid-interop-17.1.0.dex.jar;firebase-installations-17.0.0.dex.jar;firebase-installations-interop-17.0.0.dex.jar;firebase-measurement-connector-19.0.0.dex.jar;firebase-messaging-22.0.0.dex.jar;fmx.dex.jar;fragment-1.2.5.dex.jar;google-play-licensing.dex.jar;interpolator-1.0.0.dex.jar;javax.inject-1.dex.jar;legacy-support-core-ui-1.0.0.dex.jar;legacy-support-core-utils-1.0.0.dex.jar;lifecycle-common-2.2.0.dex.jar;lifecycle-livedata-2.0.0.dex.jar;lifecycle-livedata-core-2.2.0.dex.jar;lifecycle-runtime-2.2.0.dex.jar;lifecycle-service-2.0.0.dex.jar;lifecycle-viewmodel-2.2.0.dex.jar;lifecycle-viewmodel-savedstate-2.2.0.dex.jar;listenablefuture-1.0.dex.jar;loader-1.0.0.dex.jar;localbroadcastmanager-1.0.0.dex.jar;play-services-ads-20.1.0.dex.jar;play-services-ads-base-20.1.0.dex.jar;play-services-ads-identifier-17.0.0.dex.jar;play-services-ads-lite-20.1.0.dex.jar;play-services-base-17.5.0.dex.jar;play-services-basement-17.6.0.dex.jar;play-services-cloud-messaging-16.0.0.dex.jar;play-services-drive-17.0.0.dex.jar;play-services-games-21.0.0.dex.jar;play-services-location-18.0.0.dex.jar;play-services-maps-17.0.1.dex.jar;play-services-measurement-base-18.0.0.dex.jar;play-services-measurement-sdk-api-18.0.0.dex.jar;play-services-places-placereport-17.0.0.dex.jar;play-services-stats-17.0.0.dex.jar;play-services-tasks-17.2.0.dex.jar;print-1.0.0.dex.jar;room-common-2.1.0.dex.jar;room-runtime-2.1.0.dex.jar;savedstate-1.0.0.dex.jar;slidingpanelayout-1.0.0.dex.jar;sqlite-2.0.1.dex.jar;sqlite-framework-2.0.1.dex.jar;swiperefreshlayout-1.0.0.dex.jar;transport-api-3.0.0.dex.jar;transport-backend-cct-3.0.0.dex.jar;transport-runtime-3.0.0.dex.jar;user-messaging-platform-1.0.0.dex.jar;vectordrawable-1.1.0.dex.jar;vectordrawable-animated-1.1.0.dex.jar;versionedparcelable-1.1.1.dex.jar;viewpager-1.0.0.dex.jar;work-runtime-2.1.0.dex.jar</EnabledSysJars>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_iOSDevice64)'!=''">
<VerInfo_Keys>CFBundleName=$(MSBuildProjectName);CFBundleDevelopmentRegion=en;CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleInfoDictionaryVersion=7.1;CFBundleVersion=1.0.0;CFBundleShortVersionString=1.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;LSRequiresIPhoneOS=true;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);UIDeviceFamily=iPhone &amp; iPad;NSLocationAlwaysUsageDescription=The reason for accessing the location information of the user;NSLocationWhenInUseUsageDescription=The reason for accessing the location information of the user;NSLocationAlwaysAndWhenInUseUsageDescription=The reason for accessing the location information of the user;UIBackgroundModes=;NSContactsUsageDescription=The reason for accessing the contacts;NSPhotoLibraryUsageDescription=The reason for accessing the photo library;NSPhotoLibraryAddUsageDescription=The reason for adding to the photo library;NSCameraUsageDescription=The reason for accessing the camera;NSFaceIDUsageDescription=The reason for accessing the face id;NSMicrophoneUsageDescription=The reason for accessing the microphone;NSSiriUsageDescription=The reason for accessing Siri;ITSAppUsesNonExemptEncryption=false;NSBluetoothAlwaysUsageDescription=The reason for accessing bluetooth;NSBluetoothPeripheralUsageDescription=The reason for accessing bluetooth peripherals;NSCalendarsUsageDescription=The reason for accessing the calendar data;NSRemindersUsageDescription=The reason for accessing the reminders;NSMotionUsageDescription=The reason for accessing the accelerometer;NSSpeechRecognitionUsageDescription=The reason for requesting to send user data to Apple&apos;s speech recognition servers</VerInfo_Keys>
<VerInfo_UIDeviceFamily>iPhoneAndiPad</VerInfo_UIDeviceFamily>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<BT_BuildType>Debug</BT_BuildType>
<VerInfo_BundleId>$(MSBuildProjectName)</VerInfo_BundleId>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_iOSSimARM64)'!=''">
<VerInfo_Keys>CFBundleName=$(MSBuildProjectName);CFBundleDevelopmentRegion=en;CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleInfoDictionaryVersion=7.1;CFBundleVersion=1.0.0;CFBundleShortVersionString=1.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;LSRequiresIPhoneOS=true;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);UIDeviceFamily=iPhone &amp; iPad;NSLocationAlwaysUsageDescription=The reason for accessing the location information of the user;NSLocationWhenInUseUsageDescription=The reason for accessing the location information of the user;NSLocationAlwaysAndWhenInUseUsageDescription=The reason for accessing the location information of the user;UIBackgroundModes=;NSContactsUsageDescription=The reason for accessing the contacts;NSPhotoLibraryUsageDescription=The reason for accessing the photo library;NSPhotoLibraryAddUsageDescription=The reason for adding to the photo library;NSCameraUsageDescription=The reason for accessing the camera;NSFaceIDUsageDescription=The reason for accessing the face id;NSMicrophoneUsageDescription=The reason for accessing the microphone;NSSiriUsageDescription=The reason for accessing Siri;ITSAppUsesNonExemptEncryption=false;NSBluetoothAlwaysUsageDescription=The reason for accessing bluetooth;NSBluetoothPeripheralUsageDescription=The reason for accessing bluetooth peripherals;NSCalendarsUsageDescription=The reason for accessing the calendar data;NSRemindersUsageDescription=The reason for accessing the reminders;NSMotionUsageDescription=The reason for accessing the accelerometer;NSSpeechRecognitionUsageDescription=The reason for requesting to send user data to Apple&apos;s speech recognition servers</VerInfo_Keys>
<VerInfo_UIDeviceFamily>iPhoneAndiPad</VerInfo_UIDeviceFamily>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_OSX64)'!=''">
<VerInfo_Keys>CFBundleName=$(MSBuildProjectName);CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleVersion=1.0.0;CFBundleShortVersionString=1.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);NSHighResolutionCapable=true;LSApplicationCategoryType=public.app-category.utilities;NSLocationUsageDescription=The reason for accessing the location information of the user;NSContactsUsageDescription=The reason for accessing the contacts;NSCalendarsUsageDescription=The reason for accessing the calendar data;NSRemindersUsageDescription=The reason for accessing the reminders;NSCameraUsageDescription=The reason for accessing the camera;NSMicrophoneUsageDescription=The reason for accessing the microphone;NSMotionUsageDescription=The reason for accessing the accelerometer;NSDesktopFolderUsageDescription=The reason for accessing the Desktop folder;NSDocumentsFolderUsageDescription=The reason for accessing the Documents folder;NSDownloadsFolderUsageDescription=The reason for accessing the Downloads folder;NSNetworkVolumesUsageDescription=The reason for accessing files on a network volume;NSRemovableVolumesUsageDescription=The reason for accessing files on a removable volume;NSSpeechRecognitionUsageDescription=The reason for requesting to send user data to Apple&apos;s speech recognition servers;ITSAppUsesNonExemptEncryption=false;NSBluetoothAlwaysUsageDescription=The reason for accessing the Bluetooth interface</VerInfo_Keys>
<BT_BuildType>Debug</BT_BuildType>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_OSXARM64)'!=''">
<VerInfo_Keys>CFBundleName=$(MSBuildProjectName);CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleVersion=1.0.0;CFBundleShortVersionString=1.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);NSHighResolutionCapable=true;LSApplicationCategoryType=public.app-category.utilities;NSLocationUsageDescription=The reason for accessing the location information of the user;NSContactsUsageDescription=The reason for accessing the contacts;NSCalendarsUsageDescription=The reason for accessing the calendar data;NSRemindersUsageDescription=The reason for accessing the reminders;NSCameraUsageDescription=The reason for accessing the camera;NSMicrophoneUsageDescription=The reason for accessing the microphone;NSMotionUsageDescription=The reason for accessing the accelerometer;NSDesktopFolderUsageDescription=The reason for accessing the Desktop folder;NSDocumentsFolderUsageDescription=The reason for accessing the Documents folder;NSDownloadsFolderUsageDescription=The reason for accessing the Downloads folder;NSNetworkVolumesUsageDescription=The reason for accessing files on a network volume;NSRemovableVolumesUsageDescription=The reason for accessing files on a removable volume;NSSpeechRecognitionUsageDescription=The reason for requesting to send user data to Apple&apos;s speech recognition servers;ITSAppUsesNonExemptEncryption=false;NSBluetoothAlwaysUsageDescription=The reason for accessing the Bluetooth interface</VerInfo_Keys>
<BT_BuildType>Debug</BT_BuildType>
</PropertyGroup>
<PropertyGroup Condition="'$(Base_Win32)'!=''">
<VerInfo_Locale>1033</VerInfo_Locale>
<DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
@ -1027,7 +1067,11 @@
<Platforms>
<Platform value="Android">False</Platform>
<Platform value="Android64">False</Platform>
<Platform value="iOSDevice64">False</Platform>
<Platform value="iOSSimARM64">False</Platform>
<Platform value="Linux64">True</Platform>
<Platform value="OSX64">False</Platform>
<Platform value="OSXARM64">False</Platform>
<Platform value="Win32">True</Platform>
<Platform value="Win64">False</Platform>
</Platforms>

View File

@ -95,7 +95,9 @@ procedure LogExitMethod(const AMethodName: string);
function Log: ILogWriter; overload;
procedure SetDefaultLogger(const aLogWriter: ILogWriter);
procedure InitializeDefaultLogger;
//procedure InitializeDefaultLogger;
function CreateLoggerWithDefaultConfiguration: ILogWriter;
{ @abstract(Use only inside DLL because dll unloading is not a safe place to shutdown threads, so call this before unload DLL)
Use this also in ISAPI dll. Check the @code(loggerproisapisample.dll) sample
}
@ -277,6 +279,16 @@ begin
LogW(ObjectToJSON(AObject));
end;
procedure InitializeDefaultLogger;
begin
{ This procedure must be called in a synchronized context
(Normally only SetDefaultLogger should be the caller) }
if not Assigned(gDefaultLogger) then
begin
gDefaultLogger := CreateLoggerWithDefaultconfiguration;
end;
end;
procedure SetDefaultLogger(const aLogWriter: ILogWriter);
begin
if gDefaultLogger = nil then
@ -302,17 +314,12 @@ begin
end;
procedure InitializeDefaultLogger;
function CreateLoggerWithDefaultConfiguration: ILogWriter;
var
lLogsFolder: String;
lFileAppender, lConsoleAppender: ILogAppender;
lAppenders: TArray<ILogAppender>;
begin
{ This procedure must be called in a synchronized context
(Normally only SetDefaultLogger should be the caller) }
if not Assigned(gDefaultLogger) then
begin
{$IF NOT DEFINED(MOBILE)}
lLogsFolder := AppPath + 'logs';
{$ELSE}
@ -334,11 +341,9 @@ begin
begin
lAppenders := [lFileAppender];
end;
gDefaultLogger := BuildLogWriter(lAppenders);
end;
Result := BuildLogWriter(lAppenders);
end;
procedure ReleaseGlobalLogger;
begin
if gDefaultLogger <> nil then

View File

@ -2772,7 +2772,7 @@ begin
except
on Ex: Exception do
begin
Log.ErrorFmt('[%s] %s [PathInfo "%s"] (Custom message: "%s")',
Log.Error('[%s] %s [PathInfo "%s"] (Custom message: "%s")',
[Ex.Classname, Ex.Message, GetRequestShortDescription(ARequest), 'Cannot create controller'], LOGGERPRO_TAG);
raise EMVCException.Create(http_status.InternalServerError,
'Cannot create controller (see log for more info)');
@ -2958,7 +2958,7 @@ begin
begin
if not CustomExceptionHandling(ESess, lSelectedController, lContext) then
begin
Log.ErrorFmt('[%s] %s [PathInfo "%s"] - %d %s (Custom message: "%s")',
Log.Error('[%s] %s [PathInfo "%s"] - %d %s (Custom message: "%s")',
[
ESess.Classname,
ESess.Message,
@ -2976,7 +2976,7 @@ begin
begin
if not CustomExceptionHandling(E, lSelectedController, lContext) then
begin
Log.ErrorFmt('[%s] %s [PathInfo "%s"] - %d %s (Custom message: "%s")',
Log.Error('[%s] %s [PathInfo "%s"] - %d %s (Custom message: "%s")',
[
E.Classname,
E.Message,
@ -3000,7 +3000,7 @@ begin
begin
if not CustomExceptionHandling(EIO, lSelectedController, lContext) then
begin
Log.ErrorFmt('[%s] %s [PathInfo "%s"] - %d %s (Custom message: "%s")',
Log.Error('[%s] %s [PathInfo "%s"] - %d %s (Custom message: "%s")',
[
EIO.Classname,
EIO.Message,
@ -3033,7 +3033,7 @@ begin
if not CustomExceptionHandling(Ex, lSelectedController, lContext) then
begin
Log.ErrorFmt('[%s] %s [PathInfo "%s"] - %d %s (Custom message: "%s")',
Log.Error('[%s] %s [PathInfo "%s"] - %d %s (Custom message: "%s")',
[
Ex.Classname,
Ex.Message,
@ -3062,7 +3062,7 @@ begin
begin
if not CustomExceptionHandling(Ex, lSelectedController, lContext) then
begin
Log.ErrorFmt('[%s] %s [PathInfo "%s"] - %d %s (Custom message: "%s")',
Log.Error('[%s] %s [PathInfo "%s"] - %d %s (Custom message: "%s")',
[
Ex.Classname,
Ex.Message,
@ -3652,7 +3652,7 @@ begin
except
on E: Exception do
begin
Log.ErrorFmt('[%s] %s', [E.Classname, E.Message], LOGGERPRO_TAG);
Log.Error('[%s] %s', [E.Classname, E.Message], LOGGERPRO_TAG);
AResponse.StatusCode := http_status.InternalServerError; // default is Internal Server Error
if E is EMVCException then
@ -4313,7 +4313,7 @@ begin
except
on E: Exception do
begin
Log.ErrorFmt('[%s] %s', [E.Classname, E.Message], LOGGERPRO_TAG);
Log.Error('[%s] %s', [E.Classname, E.Message], LOGGERPRO_TAG);
raise;
end;
end;