From 4a373591741717d8edd3c07495f959a3c1d3cb20 Mon Sep 17 00:00:00 2001 From: Brennan Date: Wed, 4 Mar 2015 20:28:47 -0800 Subject: [PATCH] Logging API changes --- src/Microsoft.AspNet.Session/DistributedSession.cs | 6 +++--- src/Microsoft.AspNet.Session/SessionMiddleware.cs | 4 ++-- test/Microsoft.AspNet.Session.Tests/SessionTests.cs | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.AspNet.Session/DistributedSession.cs b/src/Microsoft.AspNet.Session/DistributedSession.cs index f413245e14..b08d09b6f9 100644 --- a/src/Microsoft.AspNet.Session/DistributedSession.cs +++ b/src/Microsoft.AspNet.Session/DistributedSession.cs @@ -35,7 +35,7 @@ namespace Microsoft.AspNet.Session _idleTimeout = idleTimeout; _tryEstablishSession = tryEstablishSession; _store = new Dictionary(); - _logger = loggerFactory.Create(); + _logger = loggerFactory.CreateLogger(); _isNewSessionKey = isNewSessionKey; } @@ -103,7 +103,7 @@ namespace Microsoft.AspNet.Session } else if (!_isNewSessionKey) { - _logger.WriteWarning("Accessing expired session {0}", _sessionId); + _logger.LogWarning("Accessing expired session {0}", _sessionId); } _loaded = true; } @@ -116,7 +116,7 @@ namespace Microsoft.AspNet.Session Stream data; if (_logger.IsEnabled(LogLevel.Information) && !_cache.TryGetValue(_sessionId, out data)) { - _logger.WriteInformation("Session {0} started", _sessionId); + _logger.LogInformation("Session {0} started", _sessionId); } _isModified = false; _cache.Set(_sessionId, context => { diff --git a/src/Microsoft.AspNet.Session/SessionMiddleware.cs b/src/Microsoft.AspNet.Session/SessionMiddleware.cs index 47ae9793f9..11c250cb7b 100644 --- a/src/Microsoft.AspNet.Session/SessionMiddleware.cs +++ b/src/Microsoft.AspNet.Session/SessionMiddleware.cs @@ -31,7 +31,7 @@ namespace Microsoft.AspNet.Session [NotNull] ConfigureOptions configureOptions) { _next = next; - _logger = loggerFactory.Create(); + _logger = loggerFactory.CreateLogger(); if (configureOptions != null) { _options = options.GetNamedOptions(configureOptions.Name); @@ -91,7 +91,7 @@ namespace Microsoft.AspNet.Session } catch (Exception ex) { - _logger.WriteError("Error closing the session.", ex); + _logger.LogError("Error closing the session.", ex); } } } diff --git a/test/Microsoft.AspNet.Session.Tests/SessionTests.cs b/test/Microsoft.AspNet.Session.Tests/SessionTests.cs index 803008ccf6..21440052f2 100644 --- a/test/Microsoft.AspNet.Session.Tests/SessionTests.cs +++ b/test/Microsoft.AspNet.Session.Tests/SessionTests.cs @@ -210,7 +210,7 @@ namespace Microsoft.AspNet.Session var response = await client.GetAsync("/"); response.EnsureSuccessStatusCode(); Assert.Single(sink.Writes); - Assert.True(((ILoggerStructure)sink.Writes[0].State).Format().Contains("started")); + Assert.True(((ILogValues)sink.Writes[0].State).Format().Contains("started")); Assert.Equal(LogLevel.Information, sink.Writes[0].LogLevel); } } @@ -257,8 +257,8 @@ namespace Microsoft.AspNet.Session Thread.Sleep(50); Assert.Equal("2", await client.GetStringAsync("/second")); Assert.Equal(2, sink.Writes.Count); - Assert.True(((ILoggerStructure)sink.Writes[0].State).Format().Contains("started")); - Assert.True(((ILoggerStructure)sink.Writes[1].State).Format().Contains("expired")); + Assert.True(((ILogValues)sink.Writes[0].State).Format().Contains("started")); + Assert.True(((ILogValues)sink.Writes[1].State).Format().Contains("expired")); Assert.Equal(LogLevel.Information, sink.Writes[0].LogLevel); Assert.Equal(LogLevel.Warning, sink.Writes[1].LogLevel); }