Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Add TerminalConsoleAppender for console prompts
Dieser Commit ist enthalten in:
Ursprung
a7a227ed05
Commit
a044ed72de
@ -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,17 +22,24 @@ 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}"
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives shadowJar
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -56,8 +56,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
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
1
proxy/src/main/resources/log4j2.component.properties
Normale Datei
1
proxy/src/main/resources/log4j2.component.properties
Normale Datei
@ -0,0 +1 @@
|
||||
log4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
|
@ -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>
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren