package org.firefly.slf4j;

import com.firefly.utils.StringUtils;
import com.firefly.utils.log.LogFormatter;
import com.firefly.utils.log.LogItem;
import com.firefly.utils.time.SafeSimpleDateFormat;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * @author Pengtao Qiu
 */
public class CustomLogFormatter implements LogFormatter {

    @Override
    public String format(LogItem logItem) {
        String logStr = logItem.getLevel() + " >>> " + SafeSimpleDateFormat.defaultDateFormat.format(logItem.getDate());

        if (logItem.getMdcData() != null && !logItem.getMdcData().isEmpty()) {
            logStr += " >>> " + logItem.getMdcData();
        }

        if (StringUtils.hasText(logItem.getClassName())) {
            logStr += " >>> " + logItem.getClassName();
        }

        if (StringUtils.hasText(logItem.getThreadName())) {
            logStr += " >>> " + logItem.getThreadName();
        }

        logStr += " --->>> " + logItem.renderContentTemplate();
        return logStr;
    }

}

@@ -197,66 +197,8 @@
 t;%0A%0A
-import java.io.PrintWriter;%0Aimport java.io.StringWriter;%0A%0A
 /**%0A

remove redundant imports