Logging API changes
This commit is contained in:
parent
3aaa628365
commit
acdd9b9d47
|
|
@ -60,11 +60,11 @@ namespace Microsoft.AspNet.Identity
|
||||||
// TODO: Take logging level as a parameter
|
// TODO: Take logging level as a parameter
|
||||||
if (Succeeded)
|
if (Succeeded)
|
||||||
{
|
{
|
||||||
logger.WriteInformation(Resources.FormatLogIdentityResultSuccess(message));
|
logger.LogInformation(Resources.FormatLogIdentityResultSuccess(message));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.WriteWarning(Resources.FormatLogIdentityResultFailure(message, string.Join(",", Errors.Select(x => x.Code).ToList())));
|
logger.LogWarning(Resources.FormatLogIdentityResultFailure(message, string.Join(",", Errors.Select(x => x.Code).ToList())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -411,7 +411,7 @@ namespace Microsoft.AspNet.Identity
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected async virtual Task<bool> LogResultAsync(bool result, TUser user, [System.Runtime.CompilerServices.CallerMemberName] string methodName = "")
|
protected async virtual Task<bool> LogResultAsync(bool result, TUser user, [System.Runtime.CompilerServices.CallerMemberName] string methodName = "")
|
||||||
{
|
{
|
||||||
Logger.WriteInformation(Resources.FormatLoggingSigninResult(Resources.FormatLoggingResultMessage(methodName,
|
Logger.LogInformation(Resources.FormatLoggingSigninResult(Resources.FormatLoggingResultMessage(methodName,
|
||||||
await UserManager.GetUserIdAsync(user)), result));
|
await UserManager.GetUserIdAsync(user)), result));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -90,23 +90,23 @@ namespace Microsoft.AspNet.Identity
|
||||||
{
|
{
|
||||||
if (IsLockedOut)
|
if (IsLockedOut)
|
||||||
{
|
{
|
||||||
logger.WriteInformation(Resources.FormatLoggingSigninResult(message, "Lockedout"));
|
logger.LogInformation(Resources.FormatLoggingSigninResult(message, "Lockedout"));
|
||||||
}
|
}
|
||||||
else if (IsNotAllowed)
|
else if (IsNotAllowed)
|
||||||
{
|
{
|
||||||
logger.WriteInformation(Resources.FormatLoggingSigninResult(message, "NotAllowed"));
|
logger.LogInformation(Resources.FormatLoggingSigninResult(message, "NotAllowed"));
|
||||||
}
|
}
|
||||||
else if (RequiresTwoFactor)
|
else if (RequiresTwoFactor)
|
||||||
{
|
{
|
||||||
logger.WriteInformation(Resources.FormatLoggingSigninResult(message, "RequiresTwoFactor"));
|
logger.LogInformation(Resources.FormatLoggingSigninResult(message, "RequiresTwoFactor"));
|
||||||
}
|
}
|
||||||
else if (Succeeded)
|
else if (Succeeded)
|
||||||
{
|
{
|
||||||
logger.WriteInformation(Resources.FormatLoggingSigninResult(message, "Succeeded"));
|
logger.LogInformation(Resources.FormatLoggingSigninResult(message, "Succeeded"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.WriteInformation(Resources.FormatLoggingSigninResult(message, "Failed"));
|
logger.LogInformation(Resources.FormatLoggingSigninResult(message, "Failed"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1935,11 +1935,11 @@ namespace Microsoft.AspNet.Identity
|
||||||
var baseMessage = Resources.FormatLoggingResultMessage(methodName, await GetUserIdAsync(user));
|
var baseMessage = Resources.FormatLoggingResultMessage(methodName, await GetUserIdAsync(user));
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
Logger.WriteInformation(string.Format("{0} : {1}", baseMessage, result.ToString()));
|
Logger.LogInformation(string.Format("{0} : {1}", baseMessage, result.ToString()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Logger.WriteWarning(string.Format("{0} : {1}", baseMessage, result.ToString()));
|
Logger.LogWarning(string.Format("{0} : {1}", baseMessage, result.ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ namespace Microsoft.AspNet.Identity.Test
|
||||||
{
|
{
|
||||||
logStore = logStore ?? LogMessage;
|
logStore = logStore ?? LogMessage;
|
||||||
var logger = new Mock<ILogger<T>>();
|
var logger = new Mock<ILogger<T>>();
|
||||||
logger.Setup(x => x.Write(It.IsAny<LogLevel>(), It.IsAny<int>(), It.IsAny<object>(),
|
logger.Setup(x => x.Log(It.IsAny<LogLevel>(), It.IsAny<int>(), It.IsAny<object>(),
|
||||||
It.IsAny<Exception>(), It.IsAny<Func<object, Exception, string>>()))
|
It.IsAny<Exception>(), It.IsAny<Func<object, Exception, string>>()))
|
||||||
.Callback((LogLevel logLevel, int eventId, object state, Exception exception, Func<object, Exception, string> formatter) =>
|
.Callback((LogLevel logLevel, int eventId, object state, Exception exception, Func<object, Exception, string> formatter) =>
|
||||||
{ logStore.Append(state.ToString()); });
|
{ logStore.Append(state.ToString()); });
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Identity.Test
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write(LogLevel logLevel, int eventId, object state, Exception exception, Func<object, Exception, string> formatter)
|
public void Log(LogLevel logLevel, int eventId, object state, Exception exception, Func<object, Exception, string> formatter)
|
||||||
{
|
{
|
||||||
LogMessages.Add(state.ToString());
|
LogMessages.Add(state.ToString());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ namespace Microsoft.AspNet.Identity.Test
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ILogger Create(string name)
|
public ILogger CreateLogger(string name)
|
||||||
{
|
{
|
||||||
return new TestLogger();
|
return new TestLogger();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue