package cn.freemud.platform.sdk.common.log;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * All rights Reserved, Designed By www.freemud.cn
 *
 * @version V1.0
 * @Title: ${FILE_NAME}
 * @Package com.freemud.base.log
 * @Description: ${TODO}(用一句话描述该文件做什么)
 * @author: aiqi.gong
 * @date: 2017/6/21 14:33
 * @Copyright: 2017 www.freemud.cn Inc. All rights reserved.
 * 注意：本内容仅限于上海非码科技内部传阅，禁止外泄以及用于其他的商业目
 */
public class ThirdPartyLog {
    private static Logger logger = LoggerFactory.getLogger(ThirdPartyLog.class);

    public static void infoConvertJson(String trackingNo, long startTime, long endTime, BusinessSign businessSign, String url, String action, Object requestData, Object responseData, String responseCode, String message) {
        Object responseDataConvert = null;
        if (responseData instanceof String) {
            responseDataConvert = responseData;
        } else {
            responseDataConvert = JSON.toJSONString(responseData);
        }
        logger.info("trackingNo:{} startTime:{} endTime:{} elapsed-time:{} thirdPartyName:{} url:{} action:{} request:{} response:{} responseCode:{} message:{}",  trackingNo, startTime, endTime, endTime - startTime , businessSign.getKeyword(), url, action, JSONObject.toJSONString(requestData),responseDataConvert, responseCode, message);
    }
}
