Skip to content

Commit

Permalink
Merge pull request #85 from sungam3r/whitespace
Browse files Browse the repository at this point in the history
Whitespace formatting
  • Loading branch information
nblumhardt authored Nov 27, 2024
2 parents bf9b41b + 0a5bb87 commit f32d4a6
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion samples/WebApplicationSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.CreateBootstrapLogger();

Log.Information("Starting up!");

try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void Set(string propertyName, object value, bool destructureObjects = fal
if (propertyName == null) throw new ArgumentNullException(nameof(propertyName));

var collector = AmbientDiagnosticContextCollector.Current;
if (collector != null &&
if (collector != null &&
(_logger ?? Log.Logger).BindProperty(propertyName, value, destructureObjects, out var property))
{
collector.AddOrUpdate(property);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void Configure(LoggerConfiguration loggerConfiguration)
var levelSwitch = _services.GetService<LoggingLevelSwitch>();
if (levelSwitch != null)
loggerConfiguration.MinimumLevel.ControlledBy(levelSwitch);

foreach (var settings in _services.GetServices<ILoggerSettings>())
loggerConfiguration.ReadFrom.Settings(settings);

Expand All @@ -28,10 +28,10 @@ public void Configure(LoggerConfiguration loggerConfiguration)

foreach (var enricher in _services.GetServices<ILogEventEnricher>())
loggerConfiguration.Enrich.With(enricher);

foreach (var filter in _services.GetServices<ILogEventFilter>())
loggerConfiguration.Filter.With(filter);

foreach (var sink in _services.GetServices<ILogEventSink>())
loggerConfiguration.WriteTo.Sink(sink);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public static class SerilogHostBuilderExtensions
/// default, only Serilog sinks will receive events.</param>
/// <returns>The host builder.</returns>
public static IHostBuilder UseSerilog(
this IHostBuilder builder,
ILogger? logger = null,
this IHostBuilder builder,
ILogger? logger = null,
bool dispose = false,
LoggerProviderCollection? providers = null)
{
Expand Down Expand Up @@ -105,7 +105,7 @@ public static IHostBuilder UseSerilog(
{
if (builder == null) throw new ArgumentNullException(nameof(builder));
if (configureLogger == null) throw new ArgumentNullException(nameof(configureLogger));

builder.ConfigureServices((context, collection) =>
{
collection.AddSerilog(
Expand All @@ -114,7 +114,7 @@ public static IHostBuilder UseSerilog(
preserveStaticLogger: preserveStaticLogger,
writeToProviders: writeToProviders);
});

return builder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public RegisteredLogger(ILogger logger)
{
Logger = logger;
}

public ILogger Logger { get; }
}

Expand All @@ -52,8 +52,8 @@ public RegisteredLogger(ILogger logger)
/// default, only Serilog sinks will receive events.</param>
/// <returns>The service collection.</returns>
public static IServiceCollection AddSerilog(
this IServiceCollection collection,
ILogger? logger = null,
this IServiceCollection collection,
ILogger? logger = null,
bool dispose = false,
LoggerProviderCollection? providers = null)
{
Expand Down Expand Up @@ -134,17 +134,17 @@ public static IServiceCollection AddSerilog(
{
if (collection == null) throw new ArgumentNullException(nameof(collection));
if (configureLogger == null) throw new ArgumentNullException(nameof(configureLogger));

// This check is eager; replacing the bootstrap logger after calling this method is not supported.
var reloadable = Log.Logger as ReloadableLogger;
var useReload = reloadable != null && !preserveStaticLogger;

LoggerProviderCollection? loggerProviders = null;
if (writeToProviders)
{
loggerProviders = new LoggerProviderCollection();
}

collection.AddSingleton(services =>
{
ILogger logger;
Expand Down Expand Up @@ -182,11 +182,11 @@ public static IServiceCollection AddSerilog(
var logger = services.GetRequiredService<RegisteredLogger>().Logger;
return logger.ForContext(new NullEnricher());
});

collection.AddSingleton<ILoggerFactory>(services =>
{
var logger = services.GetRequiredService<RegisteredLogger>().Logger;

ILogger? registeredLogger = null;
if (preserveStaticLogger)
{
Expand All @@ -211,7 +211,7 @@ public static IServiceCollection AddSerilog(
});

ConfigureDiagnosticContext(collection, preserveStaticLogger);

return collection;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ public class LoggerSettingsConfigurationExtensionsTests
public void SinksAreInjectedFromTheServiceProvider()
{
var emittedEvents = new List<LogEvent>();

var serviceCollection = new ServiceCollection();
serviceCollection.AddSingleton<ILogEventSink>(new ListSink(emittedEvents));
using var services = serviceCollection.BuildServiceProvider();

using var logger = new LoggerConfiguration()
.ReadFrom.Services(services)
.CreateLogger();

logger.Information("Hello, world!");

var evt = Assert.Single(emittedEvents);
Assert.Equal("Hello, world!", evt!.MessageTemplate.Text);
}
Expand Down

0 comments on commit f32d4a6

Please sign in to comment.