LunaChat v2.6.0 : Refactored.
このコミットが含まれているのは:
1 親
22cfbe56a6
コミット
3e35f5fceb
40ファイル変更
+372
-300
検索条件に一致するファイルはありません
@@ -23,34 +23,35 @@ public class LunaChatLogger {
|
||||
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
private static final SimpleDateFormat dformat =
|
||||
new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
|
||||
private File file;
|
||||
private String dirPath;
|
||||
private String name;
|
||||
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param name ログ名
|
||||
*/
|
||||
public LunaChatLogger(String name) {
|
||||
|
||||
|
||||
this.name = name;
|
||||
checkDir();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ログを出力する
|
||||
* @param message ログ内容
|
||||
*/
|
||||
public synchronized void log(final String message) {
|
||||
|
||||
|
||||
checkDir();
|
||||
|
||||
|
||||
// 以降の処理を、発言処理の負荷軽減のため、非同期実行にする。(see issue #40.)
|
||||
Bukkit.getScheduler().runTaskAsynchronously(LunaChat.instance, new BukkitRunnable() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(
|
||||
LunaChat.getInstance(), new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
|
||||
FileWriter writer = null;
|
||||
try {
|
||||
writer = new FileWriter(file, true);
|
||||
@@ -72,25 +73,26 @@ public class LunaChatLogger {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ログの出力先フォルダをチェックし、変更されるなら更新する。
|
||||
*/
|
||||
private void checkDir() {
|
||||
|
||||
String temp = LunaChat.instance.getDataFolder() + File.separator +
|
||||
"logs" + File.separator + dformat.format(new Date());
|
||||
|
||||
|
||||
String temp = LunaChat.getInstance().getDataFolder() +
|
||||
File.separator + "logs" + File.separator +
|
||||
dformat.format(new Date());
|
||||
|
||||
if ( temp.equals(dirPath) ) {
|
||||
return;
|
||||
}
|
||||
dirPath = temp;
|
||||
|
||||
|
||||
File dir = new File(dirPath);
|
||||
if ( !dir.exists() || !dir.isDirectory() ) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
|
||||
file = new File(dir, name + ".log");
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする