package tbone;

import com.amazon.speech.speechlet.Speechlet;
import com.amazon.speech.speechlet.lambda.SpeechletRequestStreamHandler;
import com.google.inject.Guice;
import com.google.inject.Injector;
import tbone.di.GuiceModule;

import java.util.Collections;
import java.util.Set;

import static com.google.common.base.Preconditions.checkNotNull;

public class TboneSpeechletRequestStreamHandler extends SpeechletRequestStreamHandler {
    private static final String SUPPORTED_APPLICATION_ID = "SUPPORTED_APPLICATION_ID";

    private static final Injector injector = Guice.createInjector(new GuiceModule());

    public TboneSpeechletRequestStreamHandler() {
        super(
            injector.getInstance(Speechlet.class),
            getSupportedApplicationIds());
    }

    private static Set<String> getSupportedApplicationIds() {
        String supportedApplicationId = System.getenv(SUPPORTED_APPLICATION_ID);
        return Collections.singleton(
            checkNotNull(
                supportedApplicationId,
                "missing environment variable: '{}'",
                SUPPORTED_APPLICATION_ID));
    }
}

@@ -195,16 +195,73 @@
 jector;%0A
+import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A
 import t
@@ -281,16 +281,16 @@
 Module;%0A
-
 %0Aimport 
@@ -662,16 +662,121 @@
 dule());
+%0A    private static final Logger log = LoggerFactory.getLogger(TboneSpeechletRequestStreamHandler.class);
 %0A%0A    pu
@@ -993,24 +993,24 @@
 tionIds() %7B%0A
-
         Stri
@@ -1078,16 +1078,95 @@
 ON_ID);%0A
+        log.info(%22%7B%7D = %7B%7D%22, SUPPORTED_APPLICATION_ID, supportedApplicationId);%0A
         

add log msg