@@ -0,0 +1,2536 @@
+/*%0ACopyright 2017 Rice University%0A%0ALicensed under the Apache License, Version 2.0 (the %22License%22);%0Ayou may not use this file except in compliance with the License.%0AYou may obtain a copy of the License at%0A%0A    http://www.apache.org/licenses/LICENSE-2.0%0A%0AUnless required by applicable law or agreed to in writing, software%0Adistributed under the License is distributed on an %22AS IS%22 BASIS,%0AWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0ASee the License for the specific language governing permissions and%0Alimitations under the License.%0A*/%0Apackage edu.rice.cs.caper.bayou.application.api_synthesis_server.synthesis_logging;%0A%0Aimport org.apache.logging.log4j.LogManager;%0Aimport org.apache.logging.log4j.Logger;%0Aimport org.json.JSONArray;%0Aimport org.json.JSONObject;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0Aimport java.nio.file.Files;%0Aimport java.text.DateFormat;%0Aimport java.util.Date;%0Aimport java.util.UUID;%0A%0A/**%0A * A SynthesisLogger that stores the log message in a local file. Stores log messages as a JSON string using UTF-8 encoding.%0A */%0Apublic class SynthesisLoggerLocal implements SynthesisLogger %7B%0A%0A    /**%0A     * Place to send application logging information.%0A     */%0A    private static final Logger _logger = LogManager.getLogger(SynthesisLoggerLocal.class.getName());%0A%0A    @Override%0A    public void log(UUID requestId, String searchCode, Iterable%3CString%3E results)%0A    %7B%0A        _logger.debug(%22entering%22);%0A%0A        /*%0A         * Make the log message to store in local file.%0A         */%0A        String logMsg;%0A        %7B%0A            long now = System.currentTimeMillis();%0A%0A            JSONObject recordObj = new JSONObject();%0A            recordObj.put(%22version%22, %221%22);%0A            recordObj.put(%22requestId%22, requestId);%0A            recordObj.put(%22searchCode%22, searchCode);%0A            recordObj.put(%22logMomentUtc%22, now);%0A            recordObj.put(%22logMomentHuman%22, DateFormat.getDateTimeInstance().format(new Date(now)));%0A%0A            JSONArray resultsArray = new JSONArray();%0A            for (String result : results)%0A            %7B%0A                resultsArray.put(result);%0A            %7D%0A%0A            recordObj.put(%22results%22, resultsArray);%0A%0A            logMsg = recordObj.toString(1);%0A        %7D%0A%0A        String objectKey = requestId.toString() + %22.txt%22;%0A        try %7B%0A            Files.write(new File(%22logs%22, objectKey).toPath(), logMsg.getBytes());%0A        %7D catch (IOException e) %7B%0A            _logger.debug(%22could not log synth request%22);%0A        %7D%0A%0A        _logger.debug(%22exiting%22);%0A    %7D%0A%0A%7D%0A

Add class for local logging of synthesis requests