-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #110 from akkadotnet/dev
1.4.8 Release
- Loading branch information
Showing
5 changed files
with
307 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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,2 +1,7 @@ | ||
#### 1.4.8 June 23 2020 #### | ||
|
||
* Updated to [Akka.NET v1.4.8](https://github.com/akkadotnet/akka.net/releases/tag/1.4.8) | ||
* Support for exceptions logging in non-error log levels [#109](https://github.com/akkadotnet/Akka.Logger.Serilog/pull/109) | ||
|
||
#### 1.4.3 March 27 2020 #### | ||
* Updated Akka.Logger.Serilog to [Akka.NET v1.4.3](https://getakka.net/community/whats-new/akkadotnet-v1.4.html) |
This file contains 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,294 @@ | ||
using System; | ||
using Akka.Actor; | ||
using Akka.Configuration; | ||
using Akka.Event; | ||
using FluentAssertions; | ||
using Serilog; | ||
using Serilog.Events; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Akka.Logger.Serilog.Tests | ||
{ | ||
public class LogMessageSpecs : TestKit.Xunit2.TestKit | ||
{ | ||
public static readonly Config Config = @"akka.loglevel = DEBUG | ||
akka.loggers=[""Akka.Logger.Serilog.SerilogLogger, Akka.Logger.Serilog""]"; | ||
|
||
private readonly ILoggingAdapter _loggingAdapter; | ||
private readonly TestSink _sink = new TestSink(); | ||
|
||
public LogMessageSpecs(ITestOutputHelper helper) : base(Config, output: helper) | ||
{ | ||
global::Serilog.Log.Logger = new LoggerConfiguration() | ||
.WriteTo.Sink(_sink) | ||
.MinimumLevel.Debug() | ||
.CreateLogger(); | ||
_loggingAdapter = Sys.Log; | ||
} | ||
|
||
[Fact] | ||
public void ShouldLogDebugLevelMessage() | ||
{ | ||
var context = _loggingAdapter; | ||
|
||
_sink.Clear(); | ||
AwaitCondition(() => _sink.Writes.Count == 0); | ||
|
||
context.Debug("hi"); | ||
AwaitCondition(() => _sink.Writes.Count == 1); | ||
|
||
_sink.Writes.TryDequeue(out var logEvent).Should().BeTrue(); | ||
logEvent.Level.Should().Be(LogEventLevel.Debug); | ||
logEvent.RenderMessage().Should().Contain("hi"); | ||
} | ||
|
||
[Fact] | ||
public void ShouldLogDebugLevelMessageWithArgs() | ||
{ | ||
var context = _loggingAdapter; | ||
|
||
_sink.Clear(); | ||
AwaitCondition(() => _sink.Writes.Count == 0); | ||
|
||
context.Debug("hi {0}", "test"); | ||
AwaitCondition(() => _sink.Writes.Count == 1); | ||
|
||
_sink.Writes.TryDequeue(out var logEvent).Should().BeTrue(); | ||
logEvent.Level.Should().Be(LogEventLevel.Debug); | ||
logEvent.RenderMessage().Should().Contain("hi \"test\""); | ||
} | ||
|
||
[Fact] | ||
public void ShouldLogDebugLevelMessageWithException() | ||
{ | ||
var context = _loggingAdapter; | ||
|
||
_sink.Clear(); | ||
AwaitCondition(() => _sink.Writes.Count == 0); | ||
|
||
var exception = new Exception("BOOM!!!"); | ||
context.Debug(exception, "hi"); | ||
AwaitCondition(() => _sink.Writes.Count == 1); | ||
|
||
_sink.Writes.TryDequeue(out var logEvent).Should().BeTrue(); | ||
logEvent.Level.Should().Be(LogEventLevel.Debug); | ||
logEvent.Exception.Should().Be(exception); | ||
} | ||
|
||
[Fact] | ||
public void ShouldLogDebugLevelMessageWithArgsAndException() | ||
{ | ||
var context = _loggingAdapter; | ||
|
||
_sink.Clear(); | ||
AwaitCondition(() => _sink.Writes.Count == 0); | ||
|
||
var exception = new Exception("BOOM!!!"); | ||
context.Debug(exception, "hi {0}", "test"); | ||
AwaitCondition(() => _sink.Writes.Count == 1); | ||
|
||
_sink.Writes.TryDequeue(out var logEvent).Should().BeTrue(); | ||
logEvent.Level.Should().Be(LogEventLevel.Debug); | ||
logEvent.Exception.Should().Be(exception); | ||
} | ||
|
||
[Fact] | ||
public void ShouldLogInfoLevelMessage() | ||
{ | ||
var context = _loggingAdapter; | ||
|
||
_sink.Clear(); | ||
AwaitCondition(() => _sink.Writes.Count == 0); | ||
|
||
context.Info("hi"); | ||
AwaitCondition(() => _sink.Writes.Count == 1); | ||
|
||
_sink.Writes.TryDequeue(out var logEvent).Should().BeTrue(); | ||
logEvent.Level.Should().Be(LogEventLevel.Information); | ||
logEvent.RenderMessage().Should().Contain("hi"); | ||
} | ||
|
||
[Fact] | ||
public void ShouldLogInfoLevelMessageWithArgs() | ||
{ | ||
var context = _loggingAdapter; | ||
|
||
_sink.Clear(); | ||
AwaitCondition(() => _sink.Writes.Count == 0); | ||
|
||
context.Info("hi {0}", "test"); | ||
AwaitCondition(() => _sink.Writes.Count == 1); | ||
|
||
_sink.Writes.TryDequeue(out var logEvent).Should().BeTrue(); | ||
logEvent.Level.Should().Be(LogEventLevel.Information); | ||
logEvent.RenderMessage().Should().Contain("hi \"test\""); | ||
} | ||
|
||
[Fact] | ||
public void ShouldLogInfoLevelMessageWithException() | ||
{ | ||
var context = _loggingAdapter; | ||
|
||
_sink.Clear(); | ||
AwaitCondition(() => _sink.Writes.Count == 0); | ||
|
||
var exception = new Exception("BOOM!!!"); | ||
context.Info(exception, "hi"); | ||
AwaitCondition(() => _sink.Writes.Count == 1); | ||
|
||
_sink.Writes.TryDequeue(out var logEvent).Should().BeTrue(); | ||
logEvent.Level.Should().Be(LogEventLevel.Information); | ||
logEvent.Exception.Should().Be(exception); | ||
} | ||
|
||
[Fact] | ||
public void ShouldLogInfoLevelMessageWithArgsAndException() | ||
{ | ||
var context = _loggingAdapter; | ||
|
||
_sink.Clear(); | ||
AwaitCondition(() => _sink.Writes.Count == 0); | ||
|
||
var exception = new Exception("BOOM!!!"); | ||
context.Info(exception, "hi {0}", "test"); | ||
AwaitCondition(() => _sink.Writes.Count == 1); | ||
|
||
_sink.Writes.TryDequeue(out var logEvent).Should().BeTrue(); | ||
logEvent.Level.Should().Be(LogEventLevel.Information); | ||
logEvent.Exception.Should().Be(exception); | ||
} | ||
|
||
[Fact] | ||
public void ShouldLogWarningLevelMessage() | ||
{ | ||
var context = _loggingAdapter; | ||
|
||
_sink.Clear(); | ||
AwaitCondition(() => _sink.Writes.Count == 0); | ||
|
||
context.Warning("hi"); | ||
AwaitCondition(() => _sink.Writes.Count == 1); | ||
|
||
_sink.Writes.TryDequeue(out var logEvent).Should().BeTrue(); | ||
logEvent.Level.Should().Be(LogEventLevel.Warning); | ||
logEvent.RenderMessage().Should().Contain("hi"); | ||
} | ||
|
||
[Fact] | ||
public void ShouldLogWarningLevelMessageWithArgs() | ||
{ | ||
var context = _loggingAdapter; | ||
|
||
_sink.Clear(); | ||
AwaitCondition(() => _sink.Writes.Count == 0); | ||
|
||
context.Warning("hi {0}", "test"); | ||
AwaitCondition(() => _sink.Writes.Count == 1); | ||
|
||
_sink.Writes.TryDequeue(out var logEvent).Should().BeTrue(); | ||
logEvent.Level.Should().Be(LogEventLevel.Warning); | ||
logEvent.RenderMessage().Should().Contain("hi \"test\""); | ||
} | ||
|
||
[Fact] | ||
public void ShouldLogWarningLevelMessageWithException() | ||
{ | ||
var context = _loggingAdapter; | ||
|
||
_sink.Clear(); | ||
AwaitCondition(() => _sink.Writes.Count == 0); | ||
|
||
var exception = new Exception("BOOM!!!"); | ||
context.Warning(exception, "hi"); | ||
AwaitCondition(() => _sink.Writes.Count == 1); | ||
|
||
_sink.Writes.TryDequeue(out var logEvent).Should().BeTrue(); | ||
logEvent.Level.Should().Be(LogEventLevel.Warning); | ||
logEvent.Exception.Should().Be(exception); | ||
} | ||
|
||
[Fact] | ||
public void ShouldLogWarningLevelMessageWithArgsAndException() | ||
{ | ||
var context = _loggingAdapter; | ||
|
||
_sink.Clear(); | ||
AwaitCondition(() => _sink.Writes.Count == 0); | ||
|
||
var exception = new Exception("BOOM!!!"); | ||
context.Warning(exception, "hi {0}", "test"); | ||
AwaitCondition(() => _sink.Writes.Count == 1); | ||
|
||
_sink.Writes.TryDequeue(out var logEvent).Should().BeTrue(); | ||
logEvent.Level.Should().Be(LogEventLevel.Warning); | ||
logEvent.Exception.Should().Be(exception); | ||
} | ||
|
||
[Fact] | ||
public void ShouldLogErrorLevelMessage() | ||
{ | ||
var context = _loggingAdapter; | ||
|
||
_sink.Clear(); | ||
AwaitCondition(() => _sink.Writes.Count == 0); | ||
|
||
context.Error("hi"); | ||
AwaitCondition(() => _sink.Writes.Count == 1); | ||
|
||
_sink.Writes.TryDequeue(out var logEvent).Should().BeTrue(); | ||
logEvent.Level.Should().Be(LogEventLevel.Error); | ||
logEvent.RenderMessage().Should().Contain("hi"); | ||
} | ||
|
||
[Fact] | ||
public void ShouldLogErrorLevelMessageWithArgs() | ||
{ | ||
var context = _loggingAdapter; | ||
|
||
_sink.Clear(); | ||
AwaitCondition(() => _sink.Writes.Count == 0); | ||
|
||
context.Error("hi {0}", "test"); | ||
AwaitCondition(() => _sink.Writes.Count == 1); | ||
|
||
_sink.Writes.TryDequeue(out var logEvent).Should().BeTrue(); | ||
logEvent.Level.Should().Be(LogEventLevel.Error); | ||
logEvent.RenderMessage().Should().Contain("hi \"test\""); | ||
} | ||
|
||
[Fact] | ||
public void ShouldLogErrorLevelMessageWithException() | ||
{ | ||
var context = _loggingAdapter; | ||
|
||
_sink.Clear(); | ||
AwaitCondition(() => _sink.Writes.Count == 0); | ||
|
||
var exception = new Exception("BOOM!!!"); | ||
context.Error(exception, "hi"); | ||
AwaitCondition(() => _sink.Writes.Count == 1); | ||
|
||
_sink.Writes.TryDequeue(out var logEvent).Should().BeTrue(); | ||
logEvent.Level.Should().Be(LogEventLevel.Error); | ||
logEvent.Exception.Should().Be(exception); | ||
} | ||
|
||
[Fact] | ||
public void ShouldLogErrorLevelMessageWithArgsAndException() | ||
{ | ||
var context = _loggingAdapter; | ||
|
||
_sink.Clear(); | ||
AwaitCondition(() => _sink.Writes.Count == 0); | ||
|
||
var exception = new Exception("BOOM!!!"); | ||
context.Error(exception, "hi {0}", "test"); | ||
AwaitCondition(() => _sink.Writes.Count == 1); | ||
|
||
_sink.Writes.TryDequeue(out var logEvent).Should().BeTrue(); | ||
logEvent.Level.Should().Be(LogEventLevel.Error); | ||
logEvent.Exception.Should().Be(exception); | ||
} | ||
} | ||
} |
This file contains 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 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 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