diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2012-05-15 19:58:46 -0500 |
---|---|---|
committer | Travis Watkins <amaranth@ubuntu.com> | 2012-05-15 23:29:39 -0500 |
commit | e91169ebadf259898f76f6141d741b327f503d67 (patch) | |
tree | 1acb31d13efcb8a03ada0ccf2bb09b47b4b72895 /src/main/java/net/minecraft/server/ConsoleLogFormatter.java | |
parent | 31d488a3861e60f44703958e36d6eabe422f5f41 (diff) | |
download | craftbukkit-e91169ebadf259898f76f6141d741b327f503d67.tar craftbukkit-e91169ebadf259898f76f6141d741b327f503d67.tar.gz craftbukkit-e91169ebadf259898f76f6141d741b327f503d67.tar.lz craftbukkit-e91169ebadf259898f76f6141d741b327f503d67.tar.xz craftbukkit-e91169ebadf259898f76f6141d741b327f503d67.zip |
Add ConsoleLogFormatter for diff visibility
Diffstat (limited to 'src/main/java/net/minecraft/server/ConsoleLogFormatter.java')
-rw-r--r-- | src/main/java/net/minecraft/server/ConsoleLogFormatter.java | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/ConsoleLogFormatter.java b/src/main/java/net/minecraft/server/ConsoleLogFormatter.java new file mode 100644 index 00000000..e2f8793d --- /dev/null +++ b/src/main/java/net/minecraft/server/ConsoleLogFormatter.java @@ -0,0 +1,51 @@ +package net.minecraft.server; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.text.SimpleDateFormat; +import java.util.logging.Formatter; +import java.util.logging.Level; +import java.util.logging.LogRecord; + +final class ConsoleLogFormatter extends Formatter { + + private SimpleDateFormat a = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + ConsoleLogFormatter() {} + + public String format(LogRecord logrecord) { + StringBuilder stringbuilder = new StringBuilder(); + + stringbuilder.append(this.a.format(Long.valueOf(logrecord.getMillis()))); + Level level = logrecord.getLevel(); + + if (level == Level.FINEST) { + stringbuilder.append(" [FINEST] "); + } else if (level == Level.FINER) { + stringbuilder.append(" [FINER] "); + } else if (level == Level.FINE) { + stringbuilder.append(" [FINE] "); + } else if (level == Level.INFO) { + stringbuilder.append(" [INFO] "); + } else if (level == Level.WARNING) { + stringbuilder.append(" [WARNING] "); + } else if (level == Level.SEVERE) { + stringbuilder.append(" [SEVERE] "); + } else if (level == Level.SEVERE) { + stringbuilder.append(" [" + level.getLocalizedName() + "] "); + } + + stringbuilder.append(logrecord.getMessage()); + stringbuilder.append('\n'); + Throwable throwable = logrecord.getThrown(); + + if (throwable != null) { + StringWriter stringwriter = new StringWriter(); + + throwable.printStackTrace(new PrintWriter(stringwriter)); + stringbuilder.append(stringwriter.toString()); + } + + return stringbuilder.toString(); + } +} |