JlineLogbackAppender.java 580 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package emu.grasscutter.utils;

import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.ConsoleAppender;
import emu.grasscutter.Grasscutter;
import org.jline.reader.LineReader;

import java.util.Arrays;

public class JlineLogbackAppender extends ConsoleAppender<ILoggingEvent> {
    @Override
    protected void append(ILoggingEvent eventObject) {
        if (!started) {
            return;
        }
        Arrays.stream(
Melledy's avatar
Melledy committed
17
                new String(encoder.encode(eventObject)).split("\n\r")
18
19
20
        ).forEach(Grasscutter.getConsole()::printAbove);
    }
}