diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2012-05-15 20:18:35 -0500 |
---|---|---|
committer | Travis Watkins <amaranth@ubuntu.com> | 2012-05-16 13:21:23 -0500 |
commit | 4c8f6f2caaba24cbc3d30aa36200bde81d3e4132 (patch) | |
tree | ac3dfefc6e7684142fc9b83b72210f86eae9dbba /src/main/java/net/minecraft/server/ConsoleLogFormatter.java | |
parent | e91169ebadf259898f76f6141d741b327f503d67 (diff) | |
download | craftbukkit-4c8f6f2caaba24cbc3d30aa36200bde81d3e4132.tar craftbukkit-4c8f6f2caaba24cbc3d30aa36200bde81d3e4132.tar.gz craftbukkit-4c8f6f2caaba24cbc3d30aa36200bde81d3e4132.tar.lz craftbukkit-4c8f6f2caaba24cbc3d30aa36200bde81d3e4132.tar.xz craftbukkit-4c8f6f2caaba24cbc3d30aa36200bde81d3e4132.zip |
Add option to strip color codes from server.log file
Diffstat (limited to 'src/main/java/net/minecraft/server/ConsoleLogFormatter.java')
-rw-r--r-- | src/main/java/net/minecraft/server/ConsoleLogFormatter.java | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/main/java/net/minecraft/server/ConsoleLogFormatter.java b/src/main/java/net/minecraft/server/ConsoleLogFormatter.java index e2f8793d..2ed2a5e7 100644 --- a/src/main/java/net/minecraft/server/ConsoleLogFormatter.java +++ b/src/main/java/net/minecraft/server/ConsoleLogFormatter.java @@ -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 } } |