-
Notifications
You must be signed in to change notification settings - Fork 131
v7.0 - pin to MEC v7, including matching target frameworks #377
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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Serilog.Core; | ||
using Serilog.Events; | ||
|
||
namespace Sample; | ||
|
||
// The filter syntax in the sample configuration file is | ||
// processed by the Serilog.Filters.Expressions package. | ||
public class CustomFilter : ILogEventFilter | ||
{ | ||
readonly LogEventLevel _levelFilter; | ||
|
||
public CustomFilter(LogEventLevel levelFilter = LogEventLevel.Information) | ||
{ | ||
_levelFilter = levelFilter; | ||
} | ||
|
||
public bool IsEnabled(LogEvent logEvent) | ||
{ | ||
return logEvent.Level >= _levelFilter; | ||
} | ||
} |
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,24 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Serilog.Core; | ||
using Serilog.Events; | ||
|
||
namespace Sample; | ||
|
||
public class CustomPolicy : IDestructuringPolicy | ||
{ | ||
public bool TryDestructure(object value, ILogEventPropertyValueFactory propertyValueFactory, [NotNullWhen(true)] out LogEventPropertyValue? result) | ||
{ | ||
result = null; | ||
|
||
if (value is LoginData loginData) | ||
{ | ||
result = new StructureValue( | ||
new List<LogEventProperty> | ||
{ | ||
new("Username", new ScalarValue(loginData.Username)) | ||
}); | ||
} | ||
|
||
return (result != null); | ||
} | ||
} |
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,8 @@ | ||
namespace Sample; | ||
|
||
public class LoginData | ||
{ | ||
public string? Username; | ||
// ReSharper disable once NotAccessedField.Global | ||
public string? Password; | ||
} |
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,98 +1,46 @@ | ||
using Microsoft.Extensions.Configuration; | ||
|
||
using Sample; | ||
using Serilog; | ||
using Serilog.Core; | ||
using Serilog.Events; | ||
using Serilog.Debugging; | ||
|
||
// ReSharper disable UnusedType.Global | ||
|
||
namespace Sample; | ||
|
||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
SelfLog.Enable(Console.Error); | ||
|
||
Thread.CurrentThread.Name = "Main thread"; | ||
|
||
var configuration = new ConfigurationBuilder() | ||
.SetBasePath(Directory.GetCurrentDirectory()) | ||
.AddJsonFile(path: "appsettings.json", optional: false, reloadOnChange: true) | ||
.Build(); | ||
|
||
var logger = new LoggerConfiguration() | ||
.ReadFrom.Configuration(configuration) | ||
.CreateLogger(); | ||
|
||
logger.Information("Args: {Args}", args); | ||
|
||
do | ||
{ | ||
logger.ForContext<Program>().Information("Hello, world!"); | ||
logger.ForContext<Program>().Error("Hello, world!"); | ||
logger.ForContext(Constants.SourceContextPropertyName, "Microsoft").Warning("Hello, world!"); | ||
logger.ForContext(Constants.SourceContextPropertyName, "Microsoft").Error("Hello, world!"); | ||
logger.ForContext(Constants.SourceContextPropertyName, "MyApp.Something.Tricky").Verbose("Hello, world!"); | ||
SelfLog.Enable(Console.Error); | ||
|
||
logger.Information("Destructure with max object nesting depth:\n{@NestedObject}", | ||
new { FiveDeep = new { Two = new { Three = new { Four = new { Five = "the end" } } } } }); | ||
Thread.CurrentThread.Name = "Main thread"; | ||
|
||
logger.Information("Destructure with max string length:\n{@LongString}", | ||
new { TwentyChars = "0123456789abcdefghij" }); | ||
var configuration = new ConfigurationBuilder() | ||
.SetBasePath(Directory.GetCurrentDirectory()) | ||
.AddJsonFile(path: "appsettings.json", optional: false, reloadOnChange: true) | ||
.Build(); | ||
|
||
logger.Information("Destructure with max collection count:\n{@BigData}", | ||
new { TenItems = new[] { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" } }); | ||
var logger = new LoggerConfiguration() | ||
.ReadFrom.Configuration(configuration) | ||
.CreateLogger(); | ||
|
||
logger.Information("Destructure with policy to strip password:\n{@LoginData}", | ||
new LoginData { Username = "BGates", Password = "isityearoflinuxyet" }); | ||
logger.Information("Args: {Args}", args); | ||
|
||
Console.WriteLine("\nPress \"q\" to quit, or any other key to run again.\n"); | ||
} | ||
while (!args.Contains("--run-once") && (Console.ReadKey().KeyChar != 'q')); | ||
} | ||
} | ||
|
||
// The filter syntax in the sample configuration file is | ||
// processed by the Serilog.Filters.Expressions package. | ||
public class CustomFilter : ILogEventFilter | ||
do | ||
{ | ||
readonly LogEventLevel _levelFilter; | ||
logger.ForContext<Program>().Information("Hello, world!"); | ||
logger.ForContext<Program>().Error("Hello, world!"); | ||
logger.ForContext(Constants.SourceContextPropertyName, "Microsoft").Warning("Hello, world!"); | ||
logger.ForContext(Constants.SourceContextPropertyName, "Microsoft").Error("Hello, world!"); | ||
logger.ForContext(Constants.SourceContextPropertyName, "MyApp.Something.Tricky").Verbose("Hello, world!"); | ||
|
||
public CustomFilter(LogEventLevel levelFilter = LogEventLevel.Information) | ||
{ | ||
_levelFilter = levelFilter; | ||
} | ||
logger.Information("Destructure with max object nesting depth:\n{@NestedObject}", | ||
new { FiveDeep = new { Two = new { Three = new { Four = new { Five = "the end" } } } } }); | ||
|
||
public bool IsEnabled(LogEvent logEvent) | ||
{ | ||
return logEvent.Level >= _levelFilter; | ||
} | ||
} | ||
logger.Information("Destructure with max string length:\n{@LongString}", | ||
new { TwentyChars = "0123456789abcdefghij" }); | ||
|
||
public class LoginData | ||
{ | ||
public string? Username; | ||
// ReSharper disable once NotAccessedField.Global | ||
public string? Password; | ||
} | ||
|
||
public class CustomPolicy : IDestructuringPolicy | ||
{ | ||
public bool TryDestructure(object value, ILogEventPropertyValueFactory propertyValueFactory, out LogEventPropertyValue? result) | ||
{ | ||
result = null; | ||
logger.Information("Destructure with max collection count:\n{@BigData}", | ||
new { TenItems = new[] { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" } }); | ||
|
||
if (value is LoginData loginData) | ||
{ | ||
result = new StructureValue( | ||
new List<LogEventProperty> | ||
{ | ||
new("Username", new ScalarValue(loginData.Username)) | ||
}); | ||
} | ||
logger.Information("Destructure with policy to strip password:\n{@LoginData}", | ||
new LoginData { Username = "BGates", Password = "isityearoflinuxyet" }); | ||
|
||
return (result != null); | ||
} | ||
Console.WriteLine("\nPress \"q\" to quit, or any other key to run again.\n"); | ||
} | ||
while (!args.Contains("--run-once") && (Console.ReadKey().KeyChar != 'q')); |
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
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
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.
serilog/serilog#1907