13
0
geforkt von Mirrors/Velocity

Merge pull request #26 from Minecrell/tca

Add TerminalConsoleAppender for console prompts
Dieser Commit ist enthalten in:
Andrew Steinborn 2018-08-07 10:38:00 -04:00 committet von GitHub
Commit beb947cc3e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
6 geänderte Dateien mit 59 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -1,6 +1,7 @@
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '2.0.4'
id 'de.sebastianboegl.shadow.transformer.log4j' version '2.1.1'
}
compileJava {
@ -21,13 +22,20 @@ jar {
dependencies {
compile project(':velocity-api')
compile project(':velocity-native')
compile "io.netty:netty-codec:${nettyVersion}"
compile "io.netty:netty-codec-http:${nettyVersion}"
compile "io.netty:netty-handler:${nettyVersion}"
compile "io.netty:netty-transport-native-epoll:${nettyVersion}"
compile "io.netty:netty-transport-native-epoll:${nettyVersion}:linux-x86_64"
compile "org.apache.logging.log4j:log4j-api:${log4jVersion}"
compile "org.apache.logging.log4j:log4j-core:${log4jVersion}"
compile 'net.minecrell:terminalconsoleappender:1.1.1'
runtime 'net.java.dev.jna:jna:4.5.2' // Needed for JLine
runtime 'com.lmax:disruptor:3.4.2' // Async loggers
testCompile "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
testCompile "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
}

Datei anzeigen

@ -1,12 +1,13 @@
package com.velocitypowered.proxy;
import com.velocitypowered.proxy.console.VelocityConsole;
public class Velocity {
public static void main(String... args) throws InterruptedException {
public static void main(String... args) {
final VelocityServer server = VelocityServer.getServer();
server.start();
Runtime.getRuntime().addShutdownHook(new Thread(server::shutdown, "Shutdown thread"));
Thread.currentThread().join();
new VelocityConsole(server).start();
}
}

Datei anzeigen

@ -57,8 +57,7 @@ public class VelocityServer implements ProxyServer {
private final CommandInvoker consoleCommandInvoker = new CommandInvoker() {
@Override
public void sendMessage(@Nonnull Component component) {
// TODO: TerminalConsoleAppender
logger.info(ComponentSerializers.PLAIN.serialize(component));
logger.info(ComponentSerializers.LEGACY.serialize(component));
}
@Override

Datei anzeigen

@ -0,0 +1,39 @@
package com.velocitypowered.proxy.console;
import com.velocitypowered.proxy.VelocityServer;
import net.minecrell.terminalconsole.SimpleTerminalConsole;
import org.jline.reader.LineReader;
import org.jline.reader.LineReaderBuilder;
public final class VelocityConsole extends SimpleTerminalConsole {
private final VelocityServer server;
public VelocityConsole(VelocityServer server) {
this.server = server;
}
@Override
protected LineReader buildReader(LineReaderBuilder builder) {
return super.buildReader(builder
.appName("Velocity")
// TODO: Command completion
);
}
@Override
protected boolean isRunning() {
return !this.server.isShutdown();
}
@Override
protected void runCommand(String command) {
this.server.getCommandManager().execute(this.server.getConsoleCommandInvoker(), command);
}
@Override
protected void shutdown() {
this.server.shutdown();
}
}

Datei anzeigen

@ -0,0 +1 @@
log4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector

Datei anzeigen

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg%n"/>
</Console>
<TerminalConsole name="TerminalConsole">
<PatternLayout pattern="%highlightError{[%d{HH:mm:ss} %level]: %minecraftFormatting{%msg}%n%xEx}"/>
</TerminalConsole>
<RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz"
immediateFlush="false">
<PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg%n"/>
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %minecraftFormatting{%msg}{strip}%n"/>
<Policies>
<TimeBasedTriggeringPolicy/>
<OnStartupTriggeringPolicy/>
@ -16,7 +16,7 @@
<Loggers>
<Root level="info">
<AppenderRef ref="Console"/>
<AppenderRef ref="TerminalConsole"/>
<AppenderRef ref="File"/>
</Root>
</Loggers>