Skip to content

Commit

Permalink
updated remote and dmscontainer appender sample
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleteti committed Aug 3, 2022
1 parent 9c29827 commit 2324626
Show file tree
Hide file tree
Showing 8 changed files with 209 additions and 135 deletions.
13 changes: 4 additions & 9 deletions LoggerPro.DMSEventStreamsAppender.pas
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ constructor TLoggerProDMSContainerAppender.Create(
aLogItemAggregationType: TDMSQueueAggregationType;
aLogExtendedInfo: TLoggerProExtendedInfo);
begin
inherited;
inherited Create;
fEventStreamsProxy := aEventStreamsProxy;
fQueueNameBase := aEventStreamsQueueNameBase;
fLogItemAggregationType := aLogItemAggregationType;
Expand All @@ -140,8 +140,6 @@ constructor TLoggerProDMSContainerAppender.Create(
end;

function TLoggerProDMSContainerAppender.CreateData(const SrcLogItem: TLogItem): TJSONObject;
var
lLog: TJSONObject;
begin
Result := nil;
try
Expand Down Expand Up @@ -188,7 +186,7 @@ function TLoggerProDMSContainerAppender.GetExtendedInfo: TJSONObject;
begin
Result := TJSONObject.Create;
try
{$IFDEF MSWINDOWS}
{$IF Defined(MSWINDOWS)}
if TLogExtendedInfo.EIUserName in fExtendedInfo then
begin
Result.S['username'] := fExtendedInfoData[TLogExtendedInfo.EIUserName];
Expand Down Expand Up @@ -220,7 +218,7 @@ function TLoggerProDMSContainerAppender.GetExtendedInfo: TJSONObject;

class function TLoggerProDMSContainerAppender.GetModuleBaseName: String;
begin
{$IF DEFINED(MSWINDOWS)}
{$IF Defined(MSWINDOWS)}
Result := TPath.ChangeExtension(TPath.GetFileName(GetModuleName(HInstance)), '');
{$ENDIF}
{$IF Defined(Android)}
Expand All @@ -234,7 +232,7 @@ class function TLoggerProDMSContainerAppender.GetModuleBaseName: String;

procedure TLoggerProDMSContainerAppender.LoadExtendedInfo;
begin
{$IF DEFINED(MSWINDOWS)}
{$IF Defined(MSWINDOWS)}
if TLogExtendedInfo.EIProcessID in fExtendedInfo then
begin
fExtendedInfoData[TLogExtendedInfo.EIProcessID] := IntToStr(GetCurrentProcessId);
Expand Down Expand Up @@ -288,7 +286,6 @@ procedure TLoggerProDMSContainerAppender.InternalWriteLog(const aLogItem: TLogIt
const aJSONObject: TJSONObject);
var
lRetryCount: Integer;
lResp: IHTTPResponse;
lJSONResp: TJSONObject;
const
MAX_RETRY_COUNT = 5;
Expand Down Expand Up @@ -324,9 +321,7 @@ procedure TLoggerProDMSContainerAppender.InternalWriteLog(const aLogItem: TLogIt

procedure TLoggerProDMSContainerAppender.WriteLog(const aLogItem: TLogItem);
var
lData: TJSONObject;
lRetryCount: Integer;
lResp: IHTTPResponse;
lJSONResp: TJSONObject;
lQueueName: string;
const
Expand Down
2 changes: 1 addition & 1 deletion samples/110_rest_appender/LoggerProConfig.pas
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface
REST_LOGS_COLLECTOR_URL = 'http://localhost:8080';
{$ENDIF}
{$IF Defined(Android)}
REST_LOGS_COLLECTOR_URL = 'http://192.168.1.7:8080';
REST_LOGS_COLLECTOR_URL = 'http://192.168.1.153:8080';
{$ENDIF}

function Log: ILogWriter;
Expand Down
205 changes: 117 additions & 88 deletions samples/110_rest_appender_mobile/RESTAppenderMobileSample.deployproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{48FD3533-AD48-4DE8-9F28-77C93385E6B1}</ProjectGuid>
<ProjectVersion>19.2</ProjectVersion>
<ProjectVersion>19.4</ProjectVersion>
<FrameworkType>VCL</FrameworkType>
<MainSource>DMSContainerESAppenderSample.dpr</MainSource>
<Base>True</Base>
Expand Down Expand Up @@ -112,17 +112,17 @@
<DCCReference Include="LoggerProConfig.pas"/>
<DCCReference Include="..\..\LoggerPro.DMSEventStreamsAppender.pas"/>
<DCCReference Include="EventStreamsRPCProxy.pas"/>
<BuildConfiguration Include="Release">
<Key>Cfg_2</Key>
<CfgParent>Base</CfgParent>
</BuildConfiguration>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
<BuildConfiguration Include="Debug">
<Key>Cfg_1</Key>
<CfgParent>Base</CfgParent>
</BuildConfiguration>
<BuildConfiguration Include="Release">
<Key>Cfg_2</Key>
<CfgParent>Base</CfgParent>
</BuildConfiguration>
</ItemGroup>
<ProjectExtensions>
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
Expand Down Expand Up @@ -158,6 +158,16 @@
<Operation>0</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidClasses">
<Platform Name="Android">
<RemoteDir>classes</RemoteDir>
<Operation>64</Operation>
</Platform>
<Platform Name="Android64">
<RemoteDir>classes</RemoteDir>
<Operation>64</Operation>
</Platform>
</DeployClass>
<DeployClass Name="AndroidClassesDexFile">
<Platform Name="Android">
<RemoteDir>classes</RemoteDir>
Expand Down Expand Up @@ -460,6 +470,11 @@
<Operation>1</Operation>
<Extensions>.framework</Extensions>
</Platform>
<Platform Name="OSXARM64">
<RemoteDir>Contents\MacOS</RemoteDir>
<Operation>1</Operation>
<Extensions>.framework</Extensions>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
</Platform>
Expand Down Expand Up @@ -487,6 +502,11 @@
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="OSXARM64">
<RemoteDir>Contents\MacOS</RemoteDir>
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
<Extensions>.dll;.bpl</Extensions>
Expand Down Expand Up @@ -515,6 +535,11 @@
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="OSXARM64">
<RemoteDir>Contents\MacOS</RemoteDir>
<Operation>1</Operation>
<Extensions>.dylib</Extensions>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
<Extensions>.bpl</Extensions>
Expand Down Expand Up @@ -544,6 +569,10 @@
<RemoteDir>Contents\Resources\StartUp\</RemoteDir>
<Operation>0</Operation>
</Platform>
<Platform Name="OSXARM64">
<RemoteDir>Contents\Resources\StartUp\</RemoteDir>
<Operation>0</Operation>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
</Platform>
Expand Down Expand Up @@ -1125,6 +1154,10 @@
<RemoteDir>..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="OSXARM64">
<RemoteDir>..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectOSXEntitlements">
<Platform Name="OSX32">
Expand All @@ -1135,6 +1168,10 @@
<RemoteDir>..\</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="OSXARM64">
<RemoteDir>..\</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectOSXInfoPList">
<Platform Name="OSX32">
Expand All @@ -1145,6 +1182,10 @@
<RemoteDir>Contents</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="OSXARM64">
<RemoteDir>Contents</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Name="ProjectOSXResource">
<Platform Name="OSX32">
Expand All @@ -1155,6 +1196,10 @@
<RemoteDir>Contents\Resources</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="OSXARM64">
<RemoteDir>Contents\Resources</RemoteDir>
<Operation>1</Operation>
</Platform>
</DeployClass>
<DeployClass Required="true" Name="ProjectOutput">
<Platform Name="Android">
Expand Down Expand Up @@ -1185,6 +1230,10 @@
<RemoteDir>Contents\MacOS</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="OSXARM64">
<RemoteDir>Contents\MacOS</RemoteDir>
<Operation>1</Operation>
</Platform>
<Platform Name="Win32">
<Operation>0</Operation>
</Platform>
Expand Down Expand Up @@ -1223,16 +1272,17 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSX64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
</Deployment>
<Platforms>
<Platform value="Win32">True</Platform>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ object MainForm: TMainForm
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Visible = True
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@ implementation

procedure TMainForm.Button1Click(Sender: TObject);
begin
Log.DebugFmt('This is a debug message with TAG1 (%s)', [fContext], 'TAG1');
Log.Debug('This is a debug message with TAG1 (%s)', [fContext], 'TAG1');
end;

procedure TMainForm.Button2Click(Sender: TObject);
begin
Log.InfoFmt('This is a info message with TAG1 (%s)', [fContext], 'TAG1');
Log.Info('This is a info message with TAG1 (%s)', [fContext], 'TAG1');
end;

procedure TMainForm.Button3Click(Sender: TObject);
begin
Log.WarnFmt('This is a warning message with TAG1 (%s)', [fContext], 'TAG1');
Log.Warn('This is a warning message with TAG1 (%s)', [fContext], 'TAG1');
end;

procedure TMainForm.Button4Click(Sender: TObject);
begin
Log.ErrorFmt('This is a error message with TAG1 (%s)', [fContext], 'TAG1');
Log.Error('This is a error message with TAG1 (%s)', [fContext], 'TAG1');
end;

procedure TMainForm.Button5Click(Sender: TObject);
Expand Down
15 changes: 9 additions & 6 deletions samples/95_dmscontainer_eventstream_logging/LoggerProConfig.pas
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ implementation

const
DMSCONTAINER_API_KEY =
'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJETVNDb250YWluZXIiLCJleHAiO' +
'jQ3Njc4NTA1MjQsIm5iZiI6MTYxNDI1MDIyNCwiaWF0IjoxNjE0MjUwMjI0LCJ1c2VyaWQiOiIx' +
'NzkiLCJyb2xlcyI6ImV2ZW50X3dyaXRlciIsImNvbnRleHRzIjoiIiwiaXNhcHlrZXkiOiIxIiwid' +
'XNlcm5hbWUiOiJ1c2VyX2xvZyJ9.d43kmUg_s8BxjWVMZgxwqNGcLoLdWXkIz-a87rw67pmmPTzC' +
'KKJcF0jlBn-C5uT__OHjEPpMbOfttEcY_GVXvg';
'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJETVNDb250YWluZXIiLCJleHAiOj'+
'Q4MTMxMTgzNTQsIm5iZiI6MTY1OTUxODA1NCwiaWF0IjoxNjU5NTE4MDU0LCJpc2FweWtleSI6Ij'+
'EiLCJ1c2VyaWQiOiIxODAiLCJyb2xlcyI6ImV2ZW50X3dyaXRlcixldmVudF9yZWFkZXIiLCJ1c2V'+
'ybmFtZSI6ImxvZ3Njb2xsZWN0b3IiLCJjb250ZXh0cyI6IiJ9.zCgh27qDgGPdpqg51KBlMk9Bnfh'+
'FlkUWSmjaKANYsoMJxsR51xnnJtoNjNefAWwA37EnOtf69IZA5wjDml_deg';

var
_Log: ILogWriter;
Expand Down Expand Up @@ -55,12 +55,15 @@ initialization
var Action: TLogErrorAction)
begin
Action := TLogErrorAction.SkipNewest;
{$IF Defined(MSWINDOWS)}
WinApi.Windows.Beep(800, 500);
{$ENDIF}
end;

DefaultLoggerProAppenderQueueSize := 10;

DMSProxy := TEventStreamsRPCProxy.Create('https://localhost/eventstreamsrpc');
//DMSProxy := TEventStreamsRPCProxy.Create('https://localhost/eventstreamsrpc');
DMSProxy := TEventStreamsRPCProxy.Create('http://dms.marr.it:8080/eventstreamsrpc');
DMSProxy.RPCExecutor.SetOnValidateServerCertificate(TAllowSelfSignedCertificates.OnValidateCertificate);

_Log := BuildLogWriter([TLoggerProDMSContainerAppender.Create(DMSProxy, DMSCONTAINER_API_KEY,
Expand Down
27 changes: 13 additions & 14 deletions unittests/UnitTests.dproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{3FEE058F-0B85-446A-8517-E7B9BCAAC8CA}</ProjectGuid>
<ProjectVersion>19.3</ProjectVersion>
<ProjectVersion>19.4</ProjectVersion>
<MainSource>UnitTests.dpr</MainSource>
<Base>True</Base>
<Config Condition="'$(Config)'==''">PLAINDUNITX</Config>
Expand Down Expand Up @@ -82,7 +82,6 @@
<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
<DCC_MapFile>3</DCC_MapFile>
<VerInfo_Keys>CompanyName=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName)</VerInfo_Keys>
<DCC_UnitSearchPath>..\;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
<Manifest_File>None</Manifest_File>
<VerInfo_Locale>1033</VerInfo_Locale>
<DCC_RemoteDebug>false</DCC_RemoteDebug>
Expand Down Expand Up @@ -138,9 +137,8 @@
</Excluded_Packages>
</Delphi.Personality>
<Deployment Version="3">
<DeployFile LocalName="Win32\Debug\UnitTests.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win32">
<RemoteName>UnitTests.exe</RemoteName>
<DeployFile LocalName="$(BDS)\Redist\iossimulator\libcgunwind.1.0.dylib" Class="DependencyModule">
<Platform Name="iOSSimulator">
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
Expand All @@ -154,8 +152,9 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\Redist\iossimulator\libcgunwind.1.0.dylib" Class="DependencyModule">
<Platform Name="iOSSimulator">
<DeployFile LocalName="Win32\Debug\UnitTests.exe" Configuration="Debug" Class="ProjectOutput">
<Platform Name="Win32">
<RemoteName>UnitTests.exe</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
Expand Down Expand Up @@ -948,17 +947,17 @@
<Operation>1</Operation>
</Platform>
</DeployClass>
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSX64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
<ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSX64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
</Deployment>
<Platforms>
<Platform value="Win32">True</Platform>
Expand Down

0 comments on commit 2324626

Please sign in to comment.