All Downloads are FREE. Search and download functionalities are using the official Maven repository.

top.crossoverjie.cicada.base.log.HighlightingCompositeConverterEx Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package top.crossoverjie.cicada.base.log;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.pattern.color.ANSIConstants;
import ch.qos.logback.core.pattern.color.ForegroundCompositeConverterBase;

/**
 * Function:
 *
 * @author crossoverJie
 *         Date: 2018/11/18 22:43
 * @since JDK 1.8
 */
public class HighlightingCompositeConverterEx extends ForegroundCompositeConverterBase {

    @Override
    protected String getForegroundColorCode(ILoggingEvent event) {
        Level level = event.getLevel();
        switch (level.toInt()) {
            case Level.ERROR_INT:
                return ANSIConstants.BOLD + ANSIConstants.RED_FG;
            case Level.WARN_INT:
                return ANSIConstants.RED_FG;
            case Level.INFO_INT:
                return ANSIConstants.BOLD + ANSIConstants.GREEN_FG;
            default:
                return ANSIConstants.DEFAULT_FG;
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy