Add option to strip color codes from server.log file
Dieser Commit ist enthalten in:
Ursprung
e91169ebad
Commit
4c8f6f2caa
@ -10,8 +10,14 @@ import java.util.logging.LogRecord;
|
||||
final class ConsoleLogFormatter extends Formatter {
|
||||
|
||||
private SimpleDateFormat a = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// CraftBukkit start - add color stripping, change constructor to take it
|
||||
private java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]");
|
||||
private boolean strip = false;
|
||||
|
||||
ConsoleLogFormatter() {}
|
||||
ConsoleLogFormatter(boolean strip) {
|
||||
this.strip = strip;
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
public String format(LogRecord logrecord) {
|
||||
StringBuilder stringbuilder = new StringBuilder();
|
||||
@ -46,6 +52,12 @@ final class ConsoleLogFormatter extends Formatter {
|
||||
stringbuilder.append(stringwriter.toString());
|
||||
}
|
||||
|
||||
return stringbuilder.toString();
|
||||
// CraftBukkit start - handle stripping color
|
||||
if (this.strip) {
|
||||
return this.pattern.matcher(stringbuilder.toString()).replaceAll("");
|
||||
} else {
|
||||
return stringbuilder.toString();
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class ConsoleLogManager {
|
||||
|
||||
// CraftBukkit - change of method signature!
|
||||
public static void init(MinecraftServer server) {
|
||||
ConsoleLogFormatter consolelogformatter = new ConsoleLogFormatter();
|
||||
ConsoleLogFormatter consolelogformatter = new ConsoleLogFormatter(server.options.has("log-strip-color")); // CraftBukkit - pass strip color option
|
||||
|
||||
a.setUseParentHandlers(false);
|
||||
// CraftBukkit start
|
||||
|
@ -87,6 +87,12 @@ public class Main {
|
||||
.defaultsTo(true)
|
||||
.describedAs("Log append");
|
||||
|
||||
acceptsAll(asList("log-strip-color"), "Whether to strip color codes from log file")
|
||||
.withRequiredArg()
|
||||
.ofType(Boolean.class)
|
||||
.defaultsTo(false)
|
||||
.describedAs("Log stripping");
|
||||
|
||||
acceptsAll(asList("b", "bukkit-settings"), "File for bukkit settings")
|
||||
.withRequiredArg()
|
||||
.ofType(File.class)
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren