Skip to content

Commit

Permalink
Merge pull request #203 from datalust/dev
Browse files Browse the repository at this point in the history
6.0.0 Release
  • Loading branch information
nblumhardt authored Nov 15, 2023
2 parents fb033d7 + dcc4cc2 commit c6de2ef
Show file tree
Hide file tree
Showing 33 changed files with 1,515 additions and 1,626 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ artifacts:
deploy:
- provider: NuGet
api_key:
secure: TvgNpWJrz95fIzB0+OHqDpzjVgN1BYY9ogCPmYdpmXs3Q7yuya3sz0TQc9UlvJrk
secure: 50FmAHNDUONde6WmXHMoPBZ3uW82emXRQsr9zYNotYctEMFN+k15Y830yj/cgggk
skip_symbols: true
on:
branch: /^(main|dev)$/
Expand Down
6 changes: 3 additions & 3 deletions sample/BlazorWasm/BlazorWasm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.0" PrivateAssets="all" />
<PackageReference Include="serilog.extensions.logging" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.11" PrivateAssets="all" />
<PackageReference Include="serilog.extensions.logging" Version="7.0.0" />
<PackageReference Include="serilog.sinks.browserconsole" Version="1.0.0" />
</ItemGroup>

Expand Down
257 changes: 130 additions & 127 deletions src/Serilog.Sinks.Seq/SeqLoggerConfigurationExtensions.cs

Large diffs are not rendered by default.

58 changes: 14 additions & 44 deletions src/Serilog.Sinks.Seq/Serilog.Sinks.Seq.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>Serilog sink that writes to the Seq log server over HTTP/HTTPS.</Description>
<VersionPrefix>5.2.3</VersionPrefix>
<Authors>Serilog Contributors</Authors>
<Copyright>Copyright © Serilog Contributors</Copyright>
<TargetFrameworks>net5.0;netstandard1.1;netstandard1.3;netstandard2.0;net4.5;netcoreapp3.1</TargetFrameworks>
<Description>A Serilog sink that writes events to Seq using newline-delimited JSON and HTTP/HTTPS.</Description>
<VersionPrefix>6.0.0</VersionPrefix>
<Authors>Serilog Contributors;Serilog.Sinks.Seq Contributors;Datalust Pty Ltd</Authors>
<Copyright>Copyright © Serilog Contributors, Serilog.Sinks.Seq Contributors, Datalust Pty Ltd.</Copyright>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<RootNamespace>Serilog</RootNamespace>
Expand All @@ -16,59 +16,29 @@
<PackageIcon>icon.png</PackageIcon>
<PackageProjectUrl>https://github.com/serilog/serilog-sinks-seq</PackageProjectUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<RepositoryUrl>https://github.com/serilog/serilog-sinks-seq</RepositoryUrl>
<RepositoryUrl>https://github.com/datalust/serilog-sinks-seq</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<GenerateAssemblyVersionAttribute>true</GenerateAssemblyVersionAttribute>
<LangVersion>9</LangVersion>
<LangVersion>10</LangVersion>
<Nullable>enable</Nullable>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<DefineConstants>$(DefineConstants);DURABLE;THREADING_TIMER</DefineConstants>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<DefineConstants>$(DefineConstants);WRITE_ALL_BYTES_ASYNC;ASYNC_DISPOSE;SOCKETS_HTTP_HANDLER_ALWAYS_DEFAULT;ARCHITECTURE_WASM</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>$(DefineConstants);DURABLE;THREADING_TIMER</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<DefineConstants>$(DefineConstants);DURABLE;THREADING_TIMER;WRITE_ALL_BYTES_ASYNC;ASYNC_DISPOSE</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<DefineConstants>$(DefineConstants);DURABLE;THREADING_TIMER;WRITE_ALL_BYTES_ASYNC;ASYNC_DISPOSE;SOCKETS_HTTP_HANDLER_ALWAYS_DEFAULT;ARCHITECTURE_WASM</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net4.5' ">
<DefineConstants>$(DefineConstants);DURABLE;THREADING_TIMER;HRESULTS</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net4.5' ">
<Reference Include="System.Net.Http" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Serilog" Version="2.12.0" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="3.1.0" />
<PackageReference Include="Serilog.Formatting.Compact" Version="1.1.0" />
<PackageReference Include="Serilog.Formatting.Compact" Version="2.0.0" />
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="All" />
</ItemGroup>

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

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

<ItemGroup Condition=" '$(TargetFramework)' != 'netstandard1.1' ">
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\assets\icon.png" Pack="true" Visible="false" PackagePath="" />
<None Include="..\..\README.md" Pack="true" Visible="false" PackagePath="" />
</ItemGroup>

</Project>
58 changes: 28 additions & 30 deletions src/Serilog.Sinks.Seq/Sinks/Seq/Audit/SeqAuditSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,42 @@
using System.Threading.Tasks;
using Serilog.Core;
using Serilog.Events;
using Serilog.Formatting.Compact;
using Serilog.Formatting.Json;
using Serilog.Formatting;
using Serilog.Sinks.Seq.Http;

namespace Serilog.Sinks.Seq.Audit
{
/// <summary>
/// An <see cref="ILogEventSink"/> that synchronously propagates all <see cref="Emit"/> failures as exceptions.
/// </summary>
sealed class SeqAuditSink : ILogEventSink, IDisposable
{
readonly SeqIngestionApi _ingestionApi;
namespace Serilog.Sinks.Seq.Audit;

static readonly JsonValueFormatter JsonValueFormatter = new("$type");
/// <summary>
/// An <see cref="ILogEventSink"/> that synchronously propagates all <see cref="Emit"/> failures as exceptions.
/// </summary>
sealed class SeqAuditSink : ILogEventSink, IDisposable
{
readonly SeqIngestionApi _ingestionApi;
readonly ITextFormatter _payloadFormatter;

public SeqAuditSink(SeqIngestionApi ingestionApi)
{
_ingestionApi = ingestionApi ?? throw new ArgumentNullException(nameof(ingestionApi));
}
public SeqAuditSink(SeqIngestionApi ingestionApi, ITextFormatter payloadFormatter)
{
_ingestionApi = ingestionApi ?? throw new ArgumentNullException(nameof(ingestionApi));
_payloadFormatter = payloadFormatter ?? throw new ArgumentNullException(nameof(payloadFormatter));
}

public void Dispose()
{
_ingestionApi.Dispose();
}
public void Dispose()
{
_ingestionApi.Dispose();
}

public void Emit(LogEvent logEvent)
{
EmitAsync(logEvent).Wait();
}
public void Emit(LogEvent logEvent)
{
EmitAsync(logEvent).Wait();
}

async Task EmitAsync(LogEvent logEvent)
{
if (logEvent == null) throw new ArgumentNullException(nameof(logEvent));
async Task EmitAsync(LogEvent logEvent)
{
if (logEvent == null) throw new ArgumentNullException(nameof(logEvent));

var payload = new StringWriter();
CompactJsonFormatter.FormatEvent(logEvent, payload, JsonValueFormatter);
var payload = new StringWriter();
_payloadFormatter.Format(logEvent, payload);

await _ingestionApi.IngestAsync(payload.ToString()).ConfigureAwait(false);
}
await _ingestionApi.IngestAsync(payload.ToString()).ConfigureAwait(false);
}
}
91 changes: 46 additions & 45 deletions src/Serilog.Sinks.Seq/Sinks/Seq/Batched/BatchedSeqSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,65 +18,66 @@
using System.Linq;
using System.Threading.Tasks;
using Serilog.Events;
using Serilog.Formatting;
using Serilog.Sinks.PeriodicBatching;
using Serilog.Sinks.Seq.Http;

namespace Serilog.Sinks.Seq.Batched
namespace Serilog.Sinks.Seq.Batched;

/// <summary>
/// The default Seq sink, for use in combination with <see cref="PeriodicBatchingSink"/>.
/// </summary>
sealed class BatchedSeqSink : IBatchedLogEventSink, IDisposable
{
/// <summary>
/// The default Seq sink, for use in combination with <see cref="PeriodicBatchingSink"/>.
/// </summary>
sealed class BatchedSeqSink : IBatchedLogEventSink, IDisposable
{
static readonly TimeSpan RequiredLevelCheckInterval = TimeSpan.FromMinutes(2);
static readonly TimeSpan RequiredLevelCheckInterval = TimeSpan.FromMinutes(2);

readonly ConstrainedBufferedFormatter _formatter;
readonly SeqIngestionApi _ingestionApi;
readonly ConstrainedBufferedFormatter _payloadFormatter;
readonly SeqIngestionApi _ingestionApi;

DateTime _nextRequiredLevelCheckUtc = DateTime.UtcNow.Add(RequiredLevelCheckInterval);
readonly ControlledLevelSwitch _controlledSwitch;
DateTime _nextRequiredLevelCheckUtc = DateTime.UtcNow.Add(RequiredLevelCheckInterval);
readonly ControlledLevelSwitch _controlledSwitch;

public BatchedSeqSink(
SeqIngestionApi ingestionApi,
long? eventBodyLimitBytes,
ControlledLevelSwitch controlledSwitch)
{
_controlledSwitch = controlledSwitch ?? throw new ArgumentNullException(nameof(controlledSwitch));
_formatter = new ConstrainedBufferedFormatter(eventBodyLimitBytes);
_ingestionApi = ingestionApi ?? throw new ArgumentNullException(nameof(ingestionApi));
}
public BatchedSeqSink(
SeqIngestionApi ingestionApi,
ITextFormatter payloadFormatter,
long? eventBodyLimitBytes,
ControlledLevelSwitch controlledSwitch)
{
_controlledSwitch = controlledSwitch ?? throw new ArgumentNullException(nameof(controlledSwitch));
_payloadFormatter = new ConstrainedBufferedFormatter(eventBodyLimitBytes, payloadFormatter);
_ingestionApi = ingestionApi ?? throw new ArgumentNullException(nameof(ingestionApi));
}

public void Dispose()
{
_ingestionApi.Dispose();
}
public void Dispose()
{
_ingestionApi.Dispose();
}

// The sink must emit at least one event on startup, and the server be
// configured to set a specific level, before background level checks will be performed.
public async Task OnEmptyBatchAsync()
// The sink must emit at least one event on startup, and the server be
// configured to set a specific level, before background level checks will be performed.
public async Task OnEmptyBatchAsync()
{
if (_controlledSwitch.IsActive &&
_nextRequiredLevelCheckUtc < DateTime.UtcNow)
{
if (_controlledSwitch.IsActive &&
_nextRequiredLevelCheckUtc < DateTime.UtcNow)
{
await EmitBatchAsync(Enumerable.Empty<LogEvent>());
}
await EmitBatchAsync(Enumerable.Empty<LogEvent>());
}
}

public async Task EmitBatchAsync(IEnumerable<LogEvent> events)
{
_nextRequiredLevelCheckUtc = DateTime.UtcNow.Add(RequiredLevelCheckInterval);
public async Task EmitBatchAsync(IEnumerable<LogEvent> events)
{
_nextRequiredLevelCheckUtc = DateTime.UtcNow.Add(RequiredLevelCheckInterval);

var payload = new StringWriter();
foreach (var evt in events)
{
_formatter.Format(evt, payload);
}
var payload = new StringWriter();
foreach (var evt in events)
{
_payloadFormatter.Format(evt, payload);
}

var clefPayload = payload.ToString();
var clefPayload = payload.ToString();

var minimumAcceptedLevel = await _ingestionApi.IngestAsync(clefPayload);
var minimumAcceptedLevel = await _ingestionApi.IngestAsync(clefPayload);

_controlledSwitch.Update(minimumAcceptedLevel);
}
_controlledSwitch.Update(minimumAcceptedLevel);
}
}
}
Loading

0 comments on commit c6de2ef

Please sign in to comment.