Skip to content

Commit

Permalink
Merge pull request serilog#719 from nblumhardt/dev
Browse files Browse the repository at this point in the history
Make the return value of `LoggerConfiguration.CreateLogger()` concrete
  • Loading branch information
nblumhardt committed Apr 20, 2016
2 parents 2f6cf15 + 0bc3b21 commit 3212714
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
using Serilog.Events;
using Serilog.Parameters;

namespace Serilog.Core.Pipeline
namespace Serilog.Core
{
sealed class Logger : ILogger, ILogEventSink, IDisposable
public sealed class Logger : ILogger, ILogEventSink, IDisposable
{
readonly MessageTemplateProcessor _messageTemplateProcessor;
readonly ILogEventSink _sink;
Expand All @@ -37,7 +37,7 @@ sealed class Logger : ILogger, ILogEventSink, IDisposable
readonly LogEventLevel _minimumLevel;
readonly LoggingLevelSwitch _levelSwitch;

public Logger(
internal Logger(
MessageTemplateProcessor messageTemplateProcessor,
LogEventLevel minimumLevel,
ILogEventSink sink,
Expand All @@ -47,7 +47,7 @@ public Logger(
{
}

public Logger(
internal Logger(
MessageTemplateProcessor messageTemplateProcessor,
LoggingLevelSwitch levelSwitch,
ILogEventSink sink,
Expand Down
9 changes: 2 additions & 7 deletions src/Serilog/LoggerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using System.Linq;
using Serilog.Configuration;
using Serilog.Core;
using Serilog.Core.Pipeline;
using Serilog.Core.Sinks;
using Serilog.Events;
using Serilog.Parameters;
Expand Down Expand Up @@ -132,16 +131,12 @@ public LoggerSettingsConfiguration ReadFrom
/// <remarks>To free resources held by sinks ahead of program shutdown,
/// the returned logger may be cast to <see cref="IDisposable"/> and
/// disposed.</remarks>
public ILogger CreateLogger()
public Logger CreateLogger()
{
if (_loggerCreated)
throw new InvalidOperationException($"CreateLogger was previously called and can only be called once.");
throw new InvalidOperationException("CreateLogger was previously called and can only be called once.");
_loggerCreated = true;

if (!_logEventSinks.Any())
return new SilentLogger();


Action dispose = () =>
{
foreach (var disposable in _logEventSinks.OfType<IDisposable>())
Expand Down
7 changes: 0 additions & 7 deletions test/Serilog.Tests/LoggerConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,6 @@ public void LevelSwitchTakesPrecedenceOverMinimumLevel()
Assert.Equal(1, sink.Events.Count);
}

[Fact]
public void AnUnconfiguredLoggerShouldBeTheNullLogger()
{
var actual = new LoggerConfiguration().CreateLogger();
Assert.Equal(actual.GetType().Name, "SilentLogger");
}

[Fact]
public void LastMinimumLevelConfigurationWins()
{
Expand Down

0 comments on commit 3212714

Please sign in to comment.