-
Notifications
You must be signed in to change notification settings - Fork 34
3.0.0 Release #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
3.0.0 Release #11
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
33f97d5
Bump the `dev` branch's version
nblumhardt 8d116f9
Fix incorrect urls
andrewlock 4148a0f
Merge pull request #4 from serilog/fix-broken-links
merbla efad033
fixing repository url
MaximRouiller ad3405b
Merge pull request #5 from MaximRouiller/repositoryurl
andrewlock a6610fa
only build packaging-related commits
MV10 8ff6998
include unit-tests per discussion in tracking issue
MV10 99aa3c7
Merge pull request #6 from MV10/appveyor_source_commits
andrewlock 0dac1ce
Pull changes from https://github.com/serilog/serilog-aspnetcore/pull/…
nblumhardt 1f401ac
Fix flipped conditional
nblumhardt ac4f4cd
Diagnostic context infra for downstream middleware
nblumhardt c396419
Register diagnostic services; includes ILogger now in registered serv…
nblumhardt 414a009
Reapply some doc improvements
nblumhardt 53999fd
Merge pull request #8 from nblumhardt/add-providers
nblumhardt 83427fe
Merge pull request #9 from nblumhardt/diagnostic-context
nblumhardt d691f30
NuGet publishing key
nblumhardt 3b88ae0
Fix commit filter so that appveyor.yml changes trigger a rebuild
nblumhardt cee6a1a
Make DiagnosticContextCollector thread-safe
nblumhardt 3a5f079
`IDiagnosticContext.Add()` -> `IDiagnosticContext.Set()`; more small …
nblumhardt df57744
Probably not paranoid here to trade some actual performance for bette…
nblumhardt 55bb2a5
README trivia
nblumhardt 204fe13
Merge pull request #10 from nblumhardt/threadsafe-context
nblumhardt 8a77959
Update to Serilog.Extensions.Logging 3.0; update other non-shipping d…
nblumhardt 4632471
Play it safe, try to ensure the latest patch is installed
nblumhardt 6b932b4
Merge pull request #13 from nblumhardt/rtm-deps
nblumhardt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"sdk": { | ||
"version": "2.1.300-*" | ||
"version": "2.2.105" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=appsettings/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=benaadams/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=destructure/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Serilog/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
46 changes: 46 additions & 0 deletions
46
src/Serilog.Extensions.Hosting/Extensions/Hosting/AmbientDiagnosticContextCollector.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2019 Serilog Contributors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using System; | ||
using System.Threading; | ||
|
||
namespace Serilog.Extensions.Hosting | ||
{ | ||
class AmbientDiagnosticContextCollector : IDisposable | ||
{ | ||
static readonly AsyncLocal<AmbientDiagnosticContextCollector> AmbientCollector = | ||
new AsyncLocal<AmbientDiagnosticContextCollector>(); | ||
|
||
// The indirection here ensures that completing collection cleans up the collector in all | ||
// execution contexts. Via @benaadams' addition to `HttpContextAccessor` :-) | ||
DiagnosticContextCollector _collector; | ||
|
||
public static DiagnosticContextCollector Current => AmbientCollector.Value?._collector; | ||
|
||
public static DiagnosticContextCollector Begin() | ||
{ | ||
var value = new AmbientDiagnosticContextCollector(); | ||
value._collector = new DiagnosticContextCollector(value); | ||
AmbientCollector.Value = value; | ||
return value._collector; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_collector = null; | ||
if (AmbientCollector.Value == this) | ||
AmbientCollector.Value = null; | ||
} | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
src/Serilog.Extensions.Hosting/Extensions/Hosting/DiagnosticContext.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2019 Serilog Contributors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using System; | ||
using System.Threading; | ||
|
||
namespace Serilog.Extensions.Hosting | ||
{ | ||
/// <summary> | ||
/// Implements an ambient diagnostic context using <see cref="AsyncLocal{T}"/>. | ||
/// </summary> | ||
/// <remarks>Consumers should use <see cref="IDiagnosticContext"/> to set context properties.</remarks> | ||
public sealed class DiagnosticContext : IDiagnosticContext | ||
{ | ||
readonly ILogger _logger; | ||
|
||
/// <summary> | ||
/// Construct a <see cref="DiagnosticContext"/>. | ||
/// </summary> | ||
/// <param name="logger">A logger for binding properties in the context, or <c>null</c> to use <see cref="Log.Logger"/>.</param> | ||
public DiagnosticContext(ILogger logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
/// <summary> | ||
/// Start collecting properties to associate with the current diagnostic context. This will replace | ||
/// the active collector, if any. | ||
/// </summary> | ||
/// <returns>A collector that will receive properties added in the current diagnostic context.</returns> | ||
public DiagnosticContextCollector BeginCollection() | ||
{ | ||
return AmbientDiagnosticContextCollector.Begin(); | ||
} | ||
|
||
/// <inheritdoc cref="IDiagnosticContext.Set"/> | ||
public void Set(string propertyName, object value, bool destructureObjects = false) | ||
{ | ||
if (propertyName == null) throw new ArgumentNullException(nameof(propertyName)); | ||
|
||
var collector = AmbientDiagnosticContextCollector.Current; | ||
if (collector != null && | ||
(_logger ?? Log.Logger).BindProperty(propertyName, value, destructureObjects, out var property)) | ||
{ | ||
collector.AddOrUpdate(property); | ||
} | ||
} | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
src/Serilog.Extensions.Hosting/Extensions/Hosting/DiagnosticContextCollector.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Serilog.Events; | ||
|
||
namespace Serilog.Extensions.Hosting | ||
{ | ||
/// <summary> | ||
/// A container that receives properties added to a diagnostic context. | ||
/// </summary> | ||
public sealed class DiagnosticContextCollector : IDisposable | ||
{ | ||
readonly IDisposable _chainedDisposable; | ||
readonly object _propertiesLock = new object(); | ||
Dictionary<string, LogEventProperty> _properties = new Dictionary<string, LogEventProperty>(); | ||
|
||
/// <summary> | ||
/// Construct a <see cref="DiagnosticContextCollector"/>. | ||
/// </summary> | ||
/// <param name="chainedDisposable">An object that will be disposed to signal completion/disposal of | ||
/// the collector.</param> | ||
public DiagnosticContextCollector(IDisposable chainedDisposable) | ||
{ | ||
_chainedDisposable = chainedDisposable ?? throw new ArgumentNullException(nameof(chainedDisposable)); | ||
} | ||
|
||
/// <summary> | ||
/// Add the property to the context. | ||
/// </summary> | ||
/// <param name="property">The property to add.</param> | ||
public void AddOrUpdate(LogEventProperty property) | ||
{ | ||
if (property == null) throw new ArgumentNullException(nameof(property)); | ||
|
||
lock (_propertiesLock) | ||
{ | ||
if (_properties == null) return; | ||
_properties[property.Name] = property; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Complete the context and retrieve the properties added to it, if any. This will | ||
/// stop collection and remove the collector from the original execution context and | ||
/// any of its children. | ||
/// </summary> | ||
/// <param name="properties">The collected properties, or null if no collection is active.</param> | ||
/// <returns>True if properties could be collected.</returns> | ||
public bool TryComplete(out IEnumerable<LogEventProperty> properties) | ||
{ | ||
lock (_propertiesLock) | ||
{ | ||
properties = _properties?.Values; | ||
_properties = null; | ||
Dispose(); | ||
return properties != null; | ||
} | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void Dispose() | ||
{ | ||
_chainedDisposable.Dispose(); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2019 Serilog Contributors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
namespace Serilog | ||
{ | ||
/// <summary> | ||
/// Collects diagnostic information for packaging into wide events. | ||
/// </summary> | ||
public interface IDiagnosticContext | ||
{ | ||
/// <summary> | ||
/// Set the specified property on the current diagnostic context. The property will be collected | ||
/// and attached to the event emitted at the completion of the context. | ||
/// </summary> | ||
/// <param name="propertyName">The name of the property. Must be non-empty.</param> | ||
/// <param name="value">The property value.</param> | ||
/// <param name="destructureObjects">If true, the value will be serialized as structured | ||
/// data if possible; if false, the object will be recorded as a scalar or simple array.</param> | ||
void Set(string propertyName, object value, bool destructureObjects = false); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahhh the cargo cult of redundant namespace for non public types ;)