Created
October 14, 2015 21:52
-
-
Save hudo/39ab677888c5c78a3735 to your computer and use it in GitHub Desktop.
Logger in controller
This file contains hidden or 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
| public class OrderController : Controller | |
| { | |
| // constructor and other dependent objects | |
| [HttpPost, ValidateAntiForgeryToken] | |
| public ActionResult Pay(PayRequest request) | |
| { | |
| var order = _repository.Get(request.OrderId); | |
| _logger.InfoOperations("Trying to pay the order ", payRequest) | |
| var stopwatch = new Stopwatch(); | |
| stopwatch.Start(); | |
| try | |
| { | |
| _paymentService.SendForPayment(request); | |
| } | |
| catch(Exception e) | |
| { | |
| _logger.ErrorOperation("Error processing payment request", e); | |
| } | |
| finally | |
| { | |
| stopwatch.Stop(); | |
| _logger.DebugPerformance("Payment service executed in " + stopwatch.ElapsedMilisecunds + "ms"); | |
| } | |
| return Redirect("Index"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment