package com.heyu.api.common;

import ch.qos.logback.classic.pattern.ClassicConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;

public class LogClassicConverter extends ClassicConverter {


    @Override
    public String convert(ILoggingEvent event) {
        if (LogAspect.threadLocalNo != null && LogAspect.threadLocalNo.get() != null) {
            StringBuffer sb = new StringBuffer();
            sb.append("[").append(LogAspect.threadLocalNo.get());
            Long start = LogAspect.threadLocalTime.get();
            Long end;
            if (start != null) {
                end = System.currentTimeMillis();
                sb.append(",").append(end - start);
            }
            sb.append("]");
            return sb.toString();
        }
        return "";
    }
}
