Skip to content

Commit

Permalink
Readying release v6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaben committed Sep 20, 2024
1 parent d6a5703 commit 43f0881
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 20 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ A Serilog sink that writes events as documents to [MongoDB](http://mongodb.org).
**Package** - [Serilog.Sinks.MongoDB](http://nuget.org/packages/serilog.sinks.mongodb)
| **Platforms** - .NET 4.7.2, .NET Standard 2.0,, .NET Standard 2.1

### New in v6.x
* Upgraded to MongoDb v2.28 -- fixing breaking changes.

### New in v5.x
* Output structured MongoDB Bson logs by switching to the .MongoDBBson() extensions. Existing the .MongoDB() extensions will continue to work converting logs to Json and then to Bson.
* Rolling Log Collection Naming (Thanks to [Revazashvili](https://github.com/Revazashvili) for the PR!). MongoDBBson sink only.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014-2022 Serilog Contributors
// Copyright 2014-2024 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/Serilog.Sinks.MongoDB/Helpers/MongoDbHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014-2022 Serilog Contributors
// Copyright 2014-2024 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/Serilog.Sinks.MongoDB/Helpers/RollingIntervalHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014-2022 Serilog Contributors
// Copyright 2014-2024 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/Serilog.Sinks.MongoDB/Helpers/StringHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014-2022 Serilog Contributors
// Copyright 2014-2024 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014-2022 Serilog Contributors
// Copyright 2014-2024 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions src/Serilog.Sinks.MongoDB/Serilog.Sinks.MongoDB.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<PropertyGroup>
<PackageVersion>5.4.0</PackageVersion>
<PackageVersion>6.0.0</PackageVersion>
<Authors>Kiran Makkapati, Jaben Cargman, Serilog Contributors</Authors>
<Copyright>Copyright © Serilog Contributors 2014-2022</Copyright>
<Description>The MongoDB sink for Serilog</Description>
Expand All @@ -20,7 +20,7 @@
<PackageTags>serilog, mongodb</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageReleaseNotes>
v5.4 - Upgraded to MongoDB.Driver to version 2.19 due to vulnerabilities.
v6.0 - Upgraded to MongoDB.Driver to version 2.28 due to incompatibilities.
</PackageReleaseNotes>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Serilog.Sinks.MongoDB/Sinks/MongoDB/LogEntry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014-2022 Serilog Contributors
// Copyright 2014-2024 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014-2022 Serilog Contributors
// Copyright 2014-2024 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
30 changes: 28 additions & 2 deletions src/Serilog.Sinks.MongoDB/Sinks/MongoDB/MongoDBSink.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014-2022 Serilog Contributors
// Copyright 2014-2024 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -14,9 +14,11 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading.Tasks;

using MongoDB.Bson;
using MongoDB.Bson.Serialization;

using Serilog.Events;
Expand All @@ -37,6 +39,10 @@ static MongoDBSink()
cm.MapProperty(s => s.StackTrace);
cm.MapProperty(s => s.Data);
});

// fixes https://github.com/serilog/serilog/issues/2101
BsonTypeMapper.RegisterCustomTypeMapper(typeof(IntPtr), new CustomIntPtrMapper());
BsonTypeMapper.RegisterCustomTypeMapper(typeof(UIntPtr), new CustomIntPtrMapper());
}

public MongoDBSink(MongoDBSinkConfiguration configuration)
Expand All @@ -46,6 +52,26 @@ public MongoDBSink(MongoDBSinkConfiguration configuration)

public override Task EmitBatchAsync(IEnumerable<LogEvent> events)
{
return this.InsertMany(events.Select(@event => LogEntry.MapFrom(@event, this.IncludeMessageTemplate)));
return this.InsertMany(
events.Select(@event => LogEntry.MapFrom(@event, this.IncludeMessageTemplate)));
}

private class CustomIntPtrMapper : ICustomBsonTypeMapper
{
public bool TryMapToBsonValue(object value, [UnscopedRef] out BsonValue? bsonValue)
{
switch (value)
{
case IntPtr intPtr:
bsonValue = intPtr.ToInt32();
return true;
case UIntPtr uIntPtr:
bsonValue = uIntPtr.ToUInt32();
return true;
default:
bsonValue = null;
return false;
}
}
}
}
2 changes: 1 addition & 1 deletion src/Serilog.Sinks.MongoDB/Sinks/MongoDB/MongoDBSinkBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014-2022 Serilog Contributors
// Copyright 2014-2024 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014-2022 Serilog Contributors
// Copyright 2014-2024 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014-2022 Serilog Contributors
// Copyright 2014-2024 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014-2022 Serilog Contributors
// Copyright 2014-2024 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/Serilog.Sinks.MongoDB/Sinks/MongoDB/RollingInterval.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014-2022 Serilog Contributors
// Copyright 2014-2024 Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="FluentAssertions" Version="6.12.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NUnit" Version="4.0.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
</ItemGroup>

Expand Down

0 comments on commit 43f0881

Please sign in to comment.