Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Log exceptions in JsonInputFormatter #3626

Merged
merged 1 commit into from
Nov 30, 2015
Merged

Conversation

ryanbrandenburg
Copy link
Contributor

Fixes #3557.

@@ -72,6 +72,9 @@ public override Task<InputFormatterResult> ReadRequestBodyAsync(InputFormatterCo
return InputFormatterResult.FailureAsync();
}

var loggerFactory = context.HttpContext.RequestServices.GetRequiredService<ILoggerFactory>();
var logger = loggerFactory.CreateLogger<FileResult>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be passing this in the constructor.

@ryanbrandenburg ryanbrandenburg force-pushed the rybrande/JsonInputLogging branch from 2450bae to 9f4c671 Compare November 25, 2015 01:02
It.IsAny<object>(),
It.IsAny<Exception>(),
It.IsAny<Func<object, Exception, string>>()),
Times.Once);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This formatting hurts my eyes. What is this testing, anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That when we have an error coming out of the formatter we log the error in addition to returning it. I suppose it's probably mostly paranoia on my to double check that the logging happened, I'll remove it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just fix the indentation then? The Times.Once can't be on the same line as Mock.Get.

Try something like:

Mock
    .Get<ILogger>(logger)
    .Verify(l => l.Log(  
        LogLevel.Verbose,  
        It.IsAny<int>(),  
        It.IsAny<object>(),  
        It.IsAny<Exception>(),  
        It.IsAny<Func<object, Exception, string>>()),  
    Times.Once);  

@ryanbrandenburg ryanbrandenburg force-pushed the rybrande/JsonInputLogging branch from ce5cb8a to 10bde5c Compare November 25, 2015 19:20
@ryanbrandenburg
Copy link
Contributor Author

🆙 📅

@Eilon
Copy link
Member

Eilon commented Nov 25, 2015

:shipit:

@ryanbrandenburg ryanbrandenburg force-pushed the rybrande/JsonInputLogging branch 2 times, most recently from 713ea13 to 96d4bed Compare November 30, 2015 17:48
@ryanbrandenburg ryanbrandenburg force-pushed the rybrande/JsonInputLogging branch from 96d4bed to 91e837d Compare November 30, 2015 19:19
@ryanbrandenburg ryanbrandenburg merged commit 91e837d into dev Nov 30, 2015
@ryanbrandenburg ryanbrandenburg deleted the rybrande/JsonInputLogging branch December 7, 2015 20:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants