LunaChat v2.3.1 : Fixed issue #40.

このコミットが含まれているのは:
ucchyocean committed 2013-07-27 14:17:29 +09:00
1 親 5a806f9bd6
コミット 6e4e4ef64f
1ファイル変更
+25 -14
+25 -14
ファイルの表示
@@ -10,6 +10,9 @@ import java.io.FileWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitRunnable;
/**
* LunaChatロガー
* @author ucchy
@@ -39,27 +42,35 @@ public class LunaChatLogger {
* ログを出力する
* @param message ログ内容
*/
public void log(String message) {
public void log(final String message) {
checkDir();
FileWriter writer = null;
try {
writer = new FileWriter(file, true);
String str = lformat.format(new Date()) + "," + message;
writer.write(str + "\r\n");
writer.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
if ( writer != null ) {
// 以降の処理を、発言処理の負荷軽減のため、非同期実行にする。(see issue #40.)
Bukkit.getScheduler().runTaskAsynchronously(LunaChat.instance, new BukkitRunnable() {
@Override
public void run() {
FileWriter writer = null;
try {
writer.close();
writer = new FileWriter(file, true);
String str = lformat.format(new Date()) + "," + message;
writer.write(str + "\r\n");
writer.flush();
} catch (Exception e) {
// do nothing.
e.printStackTrace();
} finally {
if ( writer != null ) {
try {
writer.close();
} catch (Exception e) {
// do nothing.
}
}
}
}
}
});
}
/**