package com.sentibrand;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.OptionalDouble;

import static org.springframework.http.ResponseEntity.ok;
import static org.springframework.http.ResponseEntity.unprocessableEntity;
import static org.springframework.web.bind.annotation.RequestMethod.POST;

@RestController
@RequestMapping("/sentiment")
public class SentimentProcessingController {

    private final SentimentProcessingService sentimentProcessingService;
    private final SentimentResponseFactory sentimentResponseFactory;

    @Autowired
    public SentimentProcessingController(final SentimentProcessingService sentimentProcessingService,
                                         final SentimentResponseFactory sentimentResponseFactory) {
        this.sentimentProcessingService = sentimentProcessingService;
        this.sentimentResponseFactory = sentimentResponseFactory;
    }

    @RequestMapping(method = POST)
    public ResponseEntity<SentimentResponse> sentiment(@RequestBody SentimentRequest sentimentRequest) {
        OptionalDouble optionalDouble = sentimentProcessingService.forText(sentimentRequest.getText());
        return optionalDouble.isPresent() ?
                ok(sentimentResponseFactory.create(sentimentRequest, optionalDouble.getAsDouble())) :
                unprocessableEntity().body(null);
    }
}

@@ -18,16 +18,73 @@
 brand;%0A%0A
+import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A
 import o
@@ -138,16 +138,16 @@
 owired;%0A
-
 import o
@@ -707,16 +707,120 @@
 ller %7B%0A%0A
+    private static final Logger logger = LoggerFactory.getLogger(SentimentProcessingController.class);%0A%0A
     priv
@@ -1349,16 +1349,16 @@
 = POST)%0A
-
     publ
@@ -1450,24 +1450,125 @@
 tRequest) %7B%0A
+        logger.info(String.format(%22Processing sentiment for text: %25s%22, sentimentRequest.getText()));%0A
         Opti

Add logging to controller.