Logging API changes
This commit is contained in:
parent
653cb005cb
commit
4a37359174
|
|
@ -35,7 +35,7 @@ namespace Microsoft.AspNet.Session
|
|||
_idleTimeout = idleTimeout;
|
||||
_tryEstablishSession = tryEstablishSession;
|
||||
_store = new Dictionary<EncodedKey, byte[]>();
|
||||
_logger = loggerFactory.Create<DistributedSession>();
|
||||
_logger = loggerFactory.CreateLogger<DistributedSession>();
|
||||
_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 => {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace Microsoft.AspNet.Session
|
|||
[NotNull] ConfigureOptions<SessionOptions> configureOptions)
|
||||
{
|
||||
_next = next;
|
||||
_logger = loggerFactory.Create<SessionMiddleware>();
|
||||
_logger = loggerFactory.CreateLogger<SessionMiddleware>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue