/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.opensymphony.xwork2.ActionInvocation
 *  com.opensymphony.xwork2.interceptor.AbstractInterceptor
 *  org.apache.commons.logging.Log
 *  org.apache.commons.logging.LogFactory
 */
package com.hst.framework.interceptor;

import com.hst.framework.constants.WebConstants;
import com.hst.framework.util.HstDateUtil;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class HstLoggerInterceptor
extends AbstractInterceptor {
    public static Log _logger = LogFactory.getLog(HstLoggerInterceptor.class);
    private static final String START_MESSAGE = "Starting execution stack for action ";
    private static final String FINISH_MESSAGE = "Finishing execution stack for action ";

    public String intercept(ActionInvocation invocation) throws Exception {
        this.logMessage(invocation, START_MESSAGE);
        String kssj = HstDateUtil.format(HstDateUtil.getCurrentTime(), "yyyy-MM-dd HH:mm:ss");
        long start = System.currentTimeMillis();
        String result = invocation.invoke();
        String jssj = HstDateUtil.format(HstDateUtil.getCurrentTime(), "yyyy-MM-dd HH:mm:ss");
        long end = System.currentTimeMillis();
        if (WebConstants.LOG_KZ_TIME.equals("Y")) {
            this.logTimeUsed(invocation, kssj, jssj, end - start);
        }
        this.logMessage(invocation, FINISH_MESSAGE);
        return result;
    }

    public void logTimeUsed(ActionInvocation invocation, String kssj, String jssj, long timeUsed) {
        if (_logger.isInfoEnabled()) {
            StringBuilder message = new StringBuilder("");
            String namespace = invocation.getProxy().getNamespace();
            if (namespace != null && namespace.trim().length() > 0) {
                message.append(namespace).append("/");
            }
            message.append(invocation.getProxy().getActionName());
            message.append("!").append(invocation.getProxy().getMethod());
            message.append("\u5f00\u59cb\u65f6\u95f4\uff1a" + kssj + ",\u7ed3\u675f\u65f6\u95f4:" + jssj + ", \u6d88\u8017\u65f6\u95f4:" + timeUsed + "\u6beb\u79d2");
            _logger.warn((Object)message.toString());
        }
    }

    private void logMessage(ActionInvocation invocation, String baseMessage) {
        if (_logger.isInfoEnabled()) {
            StringBuilder message = new StringBuilder(baseMessage);
            String namespace = invocation.getProxy().getNamespace();
            if (namespace != null && namespace.trim().length() > 0) {
                message.append(namespace).append("/");
            }
            message.append(invocation.getProxy().getActionName());
            message.append("!").append(invocation.getProxy().getMethod());
            _logger.info((Object)message.toString());
        }
    }
}
