summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit
diff options
context:
space:
mode:
authorDinnerbone <dinnerbone@dinnerbone.com>2011-02-26 11:29:37 +0000
committerDinnerbone <dinnerbone@dinnerbone.com>2011-02-26 11:29:37 +0000
commit07b86b12306f0cb6c6002862665e8a601636d72e (patch)
treee03d6785345657d0863b50e000d90b12ec42e543 /src/main/java/org/bukkit
parentbb8d9fbe9d34e6bf26e84b1f96dfa5a3c0a1eb3c (diff)
downloadcraftbukkit-07b86b12306f0cb6c6002862665e8a601636d72e.tar
craftbukkit-07b86b12306f0cb6c6002862665e8a601636d72e.tar.gz
craftbukkit-07b86b12306f0cb6c6002862665e8a601636d72e.tar.lz
craftbukkit-07b86b12306f0cb6c6002862665e8a601636d72e.tar.xz
craftbukkit-07b86b12306f0cb6c6002862665e8a601636d72e.zip
Added command line option 'date-format' to control how dates are printed to console (not to log)
Diffstat (limited to 'src/main/java/org/bukkit')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/Main.java8
-rw-r--r--src/main/java/org/bukkit/craftbukkit/util/ShortConsoleLogFormatter.java28
2 files changed, 35 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index 2d75096f..7522fbfc 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -2,6 +2,9 @@ package org.bukkit.craftbukkit;
import java.io.File;
import java.io.IOException;
+import java.text.DateFormat;
+import java.text.Format;
+import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
@@ -53,6 +56,11 @@ public class Main {
.withRequiredArg()
.ofType(Integer.class)
.describedAs("Server size");
+
+ acceptsAll(asList("d", "date-format"), "Format of the date to display in the console (for log entries)")
+ .withRequiredArg()
+ .ofType(SimpleDateFormat.class)
+ .describedAs("Log date format");
}
};
diff --git a/src/main/java/org/bukkit/craftbukkit/util/ShortConsoleLogFormatter.java b/src/main/java/org/bukkit/craftbukkit/util/ShortConsoleLogFormatter.java
index ad4419f9..404cf32d 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/ShortConsoleLogFormatter.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/ShortConsoleLogFormatter.java
@@ -5,9 +5,35 @@ import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
+import joptsimple.OptionException;
+import joptsimple.OptionSet;
+import net.minecraft.server.MinecraftServer;
public class ShortConsoleLogFormatter extends Formatter {
- private final SimpleDateFormat date = new SimpleDateFormat("HH:mm:ss");
+ private final SimpleDateFormat date;
+
+ public ShortConsoleLogFormatter(MinecraftServer server) {
+ OptionSet options = server.options;
+ SimpleDateFormat date = null;
+
+ if (options.has("date-format")) {
+ try {
+ Object object = options.valueOf("date-format");
+
+ if ((object != null) && (object instanceof SimpleDateFormat)) {
+ date = (SimpleDateFormat)object;
+ }
+ } catch (OptionException ex) {
+ System.err.println("Given date format is not valid. Falling back to default.");
+ } finally {
+ if (date == null) {
+ date = new SimpleDateFormat("HH:mm:ss");
+ }
+ }
+ }
+
+ this.date = date;
+ }
@Override
public String format(LogRecord record) {