geforkt von Mirrors/Velocity
Removed console legacy color support (#1105)
Co-authored-by: Shane Freeder <1228900+electronicboy@users.noreply.github.com>
Dieser Commit ist enthalten in:
Ursprung
de57563eab
Commit
28acf9eac1
@ -96,6 +96,7 @@ tasks {
|
||||
dependencies {
|
||||
implementation(project(":velocity-api"))
|
||||
implementation(project(":velocity-native"))
|
||||
implementation(project(":velocity-proxy-log4j2-plugin"))
|
||||
|
||||
implementation(libs.bundles.log4j)
|
||||
implementation(libs.kyori.ansi)
|
||||
|
4
proxy/log4j2-plugin/build.gradle.kts
Normale Datei
4
proxy/log4j2-plugin/build.gradle.kts
Normale Datei
@ -0,0 +1,4 @@
|
||||
dependencies {
|
||||
implementation(libs.bundles.log4j)
|
||||
annotationProcessor(libs.log4j.core)
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Velocity Contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.velocitypowered.proxy.util;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import org.apache.logging.log4j.core.LogEvent;
|
||||
import org.apache.logging.log4j.core.config.Configuration;
|
||||
import org.apache.logging.log4j.core.config.plugins.Plugin;
|
||||
import org.apache.logging.log4j.core.layout.PatternLayout;
|
||||
import org.apache.logging.log4j.core.pattern.ConverterKeys;
|
||||
import org.apache.logging.log4j.core.pattern.LogEventPatternConverter;
|
||||
import org.apache.logging.log4j.core.pattern.PatternConverter;
|
||||
import org.apache.logging.log4j.core.pattern.PatternFormatter;
|
||||
import org.apache.logging.log4j.core.pattern.PatternParser;
|
||||
|
||||
/**
|
||||
* Strip Format Converter.
|
||||
* Based on <a href="https://github.com/PaperMC/Paper/pull/9313/files#diff-6c1396d60730e7053f0b761bdb487752467c9bc0444a4aac41908376b38a56bdR198-R233">Paper's patch</a>
|
||||
*/
|
||||
@Plugin(name = "stripAnsi", category = PatternConverter.CATEGORY)
|
||||
@ConverterKeys("stripAnsi")
|
||||
public class StripAnsiConverter extends LogEventPatternConverter {
|
||||
private static final Pattern ANSI_PATTERN = Pattern.compile("\u001B\\[[;\\d]*m");
|
||||
private final List<PatternFormatter> formatters;
|
||||
|
||||
/**
|
||||
* Constructs an instance of StripAnsiConverter.
|
||||
*/
|
||||
protected StripAnsiConverter(List<PatternFormatter> formatters) {
|
||||
super("stripAnsi", null);
|
||||
this.formatters = formatters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void format(final LogEvent event, final StringBuilder toAppendTo) {
|
||||
int start = toAppendTo.length();
|
||||
for (final PatternFormatter formatter : formatters) {
|
||||
formatter.format(event, toAppendTo);
|
||||
}
|
||||
String content = toAppendTo.substring(start);
|
||||
content = ANSI_PATTERN.matcher(content).replaceAll("");
|
||||
|
||||
toAppendTo.setLength(start);
|
||||
toAppendTo.append(content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Instance of this Converter.
|
||||
*
|
||||
* @param config the configuration
|
||||
* @param options the options
|
||||
* @return a new instance
|
||||
*/
|
||||
public static StripAnsiConverter newInstance(Configuration config, String[] options) {
|
||||
if (options.length != 1) {
|
||||
LOGGER.error("Incorrect number of options on stripFormat. Expected 1 received "
|
||||
+ options.length);
|
||||
return null;
|
||||
}
|
||||
PatternParser parser = PatternLayout.createPatternParser(config);
|
||||
List<PatternFormatter> formatters = parser.parse(options[0]);
|
||||
return new StripAnsiConverter(formatters);
|
||||
}
|
||||
}
|
@ -28,7 +28,6 @@ import net.kyori.adventure.translation.TranslationRegistry;
|
||||
import net.kyori.adventure.translation.Translator;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
/**
|
||||
* Velocity Translation Mapper.
|
||||
*/
|
||||
|
@ -22,10 +22,10 @@
|
||||
<TerminalConsole name="TerminalConsole">
|
||||
<PatternLayout>
|
||||
<LoggerNamePatternSelector
|
||||
defaultPattern="%highlightError{[%d{HH:mm:ss} %level] [%logger]: %minecraftFormatting{%msg}%n%xEx}">
|
||||
defaultPattern="%highlightError{[%d{HH:mm:ss} %level] [%logger]: %msg%n%xEx}">
|
||||
<!-- Velocity doesn't need a prefix -->
|
||||
<PatternMatch key="com.velocitypowered."
|
||||
pattern="%highlightError{[%d{HH:mm:ss} %level]: %minecraftFormatting{%msg}%n%xEx}"/>
|
||||
pattern="%highlightError{[%d{HH:mm:ss} %level]: %msg%n%xEx}"/>
|
||||
</LoggerNamePatternSelector>
|
||||
</PatternLayout>
|
||||
</TerminalConsole>
|
||||
@ -33,7 +33,7 @@
|
||||
filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz"
|
||||
immediateFlush="false">
|
||||
<PatternLayout
|
||||
pattern="[%d{HH:mm:ss}] [%t/%level] [%logger]: %minecraftFormatting{%msg}{strip}%n"/>
|
||||
pattern="[%d{HH:mm:ss}] [%t/%level] [%logger]: %stripAnsi{%msg}%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy/>
|
||||
<OnStartupTriggeringPolicy/>
|
||||
|
@ -33,6 +33,12 @@ sequenceOf(
|
||||
project(project).projectDir = file(it)
|
||||
}
|
||||
|
||||
// Include Configurate 3
|
||||
val deprecatedConfigurateModule = ":deprecated-configurate3"
|
||||
include(deprecatedConfigurateModule)
|
||||
project(deprecatedConfigurateModule).projectDir = file("proxy/deprecated/configurate3")
|
||||
|
||||
// Log4J2 plugin
|
||||
val log4j2ProxyPlugin = ":velocity-proxy-log4j2-plugin"
|
||||
include(log4j2ProxyPlugin)
|
||||
project(log4j2ProxyPlugin).projectDir = file("proxy/log4j2-plugin")
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren