ChestShop-3/com/Acrobot/ChestShop/Logging/FileWriterQueue.java
Acrobot 7b6d7d59bd - Long name (>15 chars) support
- Added Bukkit Persistence Reimplemented by LennardF1989
- Made the plugin faster
- Deleted unnecessary files (.jar size went down by 10 KB)
- Added final and private keywords
- Support for Bukkit's built-in permissions
- Updated to newest Bukkit's standard (getFace -> getRelative)
2011-07-23 21:00:47 +02:00

39 lines
945 B
Java

package com.Acrobot.ChestShop.Logging;
import com.Acrobot.ChestShop.ChestShop;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.LinkedList;
import java.util.List;
/**
* @author Acrobot
*/
public class FileWriterQueue implements Runnable {
private static final List<String> queue = new LinkedList<String>();
private static final String filePath = new File(ChestShop.folder, "ChestShop.log").getPath();
public static void addToQueue(String message) {
queue.add(message);
}
public void run() {
try {
BufferedWriter bw = new BufferedWriter(new FileWriter(filePath, true));
for (String msg : queue) {
bw.write(msg);
bw.newLine();
}
bw.close();
queue.clear();
} catch (Exception e) {
Logging.log("Couldn't write to log file!");
}
}
}