Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Commit

Permalink
Features/package upgrades (#51)
Browse files Browse the repository at this point in the history
* upgrade loggly-csharp and align system.net.http

* clean up some compiler warnings

Mainly code that can be made local and comments with semicolons considered code.

* upgrade package with minor version changes

* upgrade File sink (major version upgrade).

Adds NetCore 3.1 as a test target

* upgrade appveyor image to vs 2019

* add netcore3.1 in test project

Microsoft.NET.Test.Sdk Version="16.2.0" is the last version that will support netcoreapp1.0 (most recent packages will not run the netcoreapp tests).

* readded system.Core reference in test project

Some test will not run without it in netcoreapp 1.0

* upgrade Nsubstitute package in test project

* add ForwardedForIp example in sample project

* add push property and ForwardForIP code in sample project
  • Loading branch information
MiguelAlho authored Dec 23, 2019
1 parent eb7b6fa commit 5388575
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 34 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: '{build}'
skip_tags: true
image: Visual Studio 2017
image: Visual Studio 2019
configuration: Release
init:
- git config --global core.autocrlf false
Expand Down
14 changes: 13 additions & 1 deletion sample/sampleDurableLogger/Program.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using System.Globalization;
using System.Runtime.InteropServices;
using Loggly;
using Loggly.Config;
using Serilog;
using Serilog.Context;
using Serilog.Core;
using Serilog.Core.Enrichers;
using Serilog.Enrichers;
Expand Down Expand Up @@ -37,7 +39,15 @@ public static void Main()
logger.Warning("Third test message with {@Data}", new {P1 = "sample3", P2 = DateTime.Now});

Console.WriteLine(
"Back online messages written. Check loggly and files for data. Wait a minute or so before reconnecting. Press Enter to terminate");
"Back online messages written. Check loggly and files for data. Wait a minute or so before reconnecting. Press Enter to continue");
Console.ReadLine();

using (LogContext.PushProperty("sampleProperty", "Sample Value"))
{
logger.Information("message to send with {@Data}", new { P1 = "sample4", P2 = DateTime.Now });
}
Console.WriteLine(
"Pushed property added to object. Check loggly and data. Press Enter to terminate");
Console.ReadLine();
}
}
Expand Down Expand Up @@ -92,6 +102,8 @@ static void SetupLogglyConfiguration()
LogTransport = LogTransport.Https
};
config.ThrowExceptions = true;
//use the new Transport property that hides IP as of loggly-csharp 4.6.1.76
config.Transport.ForwardedForIp = "0.0.0.0";

//Define Tags sent to Loggly
config.TagConfig.Tags.AddRange(new ITag[]{
Expand Down
16 changes: 7 additions & 9 deletions sample/sampleDurableLogger/sampleDurableLogger.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
<TargetFramework>netcoreapp1.0</TargetFramework>
<AssemblyName>sampleDurableLogger</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>sampleDurableLogger</PackageId>
<RuntimeFrameworkVersion>1.0.4</RuntimeFrameworkVersion>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
Expand All @@ -17,17 +15,17 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="loggly-csharp" Version="4.6.1.55" />
<PackageReference Include="loggly-csharp" Version="4.6.1.76" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="Serilog" Version="2.5.0" />
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="2.1.1" />
<PackageReference Include="Serilog.Sinks.File" Version="3.2.0" />
<PackageReference Include="Serilog" Version="2.9.0" />
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="2.2.0" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
<PackageReference Include="Serilog.Sinks.RollingFileAlternate" Version="2.0.9" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.1.0" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.2" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.4.0" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
<PackageReference Include="Serilog.Enrichers.Process" Version="2.0.1" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.0.0" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
</ItemGroup>

</Project>
13 changes: 6 additions & 7 deletions src/Serilog.Sinks.Loggly/Serilog.Sinks.Loggly.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="loggly-csharp" Version="4.6.1.55" />
<PackageReference Include="loggly-csharp" Version="4.6.1.76" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="Serilog" Version="2.5.0" />
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="2.1.1" />
<PackageReference Include="Serilog.Sinks.File" Version="3.2.0" />
<PackageReference Include="Serilog" Version="2.9.0" />
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="2.2.0" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System.Net.Http" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
Expand All @@ -40,8 +39,8 @@
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.5' ">
<PackageReference Include="System.Net.Http" Version="4.3.0" />
<PackageReference Include="System.Threading.Timer" Version="4.3.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Threading.Timer" Version="4.3.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public void MoveBookmarkForward()
}

//also clear all the previous files in the set to avoid problems (and because
//they should no longer be considered); If no previous exists (index is -1);
//they should no longer be considered). If no previous exists (index is -1)
//keep existing; also do not reomve last file as it may be written to / locked
DeleteFilesInFileSetUpToIndex(fileSet, currentBookMarkedFileInFileSet + 1);
}
Expand Down Expand Up @@ -384,7 +384,7 @@ LogglyEvent DeserializeEvent(string eventLine)

FileSetPosition TryGetValidBookmark()
{
//get from the bookmark file first;
//get from the bookmark file first
FileSetPosition newBookmark = _bookmarkProvider.GetCurrentBookmarkPosition();

if (!IsValidBookmark(newBookmark))
Expand Down
9 changes: 3 additions & 6 deletions src/Serilog.Sinks.Loggly/Sinks/Loggly/HttpLogShipper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ namespace Serilog.Sinks.Loggly
class HttpLogShipper : IDisposable
{
readonly int _batchPostingLimit;
private readonly int? _retainedFileCountLimit;
readonly ExponentialBackoffConnectionSchedule _connectionSchedule;

readonly object _stateLock = new object();
Expand All @@ -43,7 +42,6 @@ class HttpLogShipper : IDisposable
readonly IFileSystemAdapter _fileSystemAdapter = new FileSystemAdapter();
readonly FileBufferDataProvider _bufferDataProvider;
readonly InvalidPayloadLogger _invalidPayloadLogger;
readonly LogglyConfigAdapter _adapter;

public HttpLogShipper(
string bufferBaseFilename,
Expand All @@ -57,15 +55,14 @@ public HttpLogShipper(
LogglyConfiguration logglyConfiguration)
{
_batchPostingLimit = batchPostingLimit;
_retainedFileCountLimit = retainedFileCountLimit;


_controlledSwitch = new ControlledLevelSwitch(levelControlSwitch);
_connectionSchedule = new ExponentialBackoffConnectionSchedule(period);

if (logglyConfiguration != null)
{
_adapter = new LogglyConfigAdapter();
_adapter.ConfigureLogglyClient(logglyConfiguration);
var adapter = new LogglyConfigAdapter();
adapter.ConfigureLogglyClient(logglyConfiguration);
}

_logglyClient = new LogglyClient(); //we'll use the loggly client instead of HTTP directly
Expand Down
18 changes: 10 additions & 8 deletions test/Serilog.Sinks.Loggly.Tests/Serilog.Sinks.Loggly.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net452;netcoreapp1.0;netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>net452;netcoreapp1.0;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<AssemblyName>Serilog.Sinks.Loggly.Tests</AssemblyName>
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageId>Serilog.Sinks.Loggly.Tests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);portable-net45+win8</PackageTargetFallback>
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">1.0.4</RuntimeFrameworkVersion>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
Expand All @@ -31,11 +30,14 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="4.19.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="NSubstitute" Version="2.0.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="FluentAssertions" Version="5.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="NSubstitute" Version="4.2.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
Expand Down

0 comments on commit 5388575

Please sign in to comment.