Skip to content

Commit b6b5c73

Browse files
committed
Avoid managing file and writes
1 parent 3c04fdc commit b6b5c73

File tree

2 files changed

+22
-53
lines changed

2 files changed

+22
-53
lines changed

flutter-idea/src/io/flutter/logging/PluginLogHandler.java

Lines changed: 0 additions & 52 deletions
This file was deleted.

flutter-idea/src/io/flutter/logging/PluginLogger.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,33 @@
55
*/
66
package io.flutter.logging;
77

8+
import com.intellij.openapi.application.PathManager;
89
import com.intellij.openapi.diagnostic.Logger;
910
import org.jetbrains.annotations.NotNull;
1011

12+
import java.io.File;
13+
import java.io.IOException;
14+
import java.util.logging.FileHandler;
15+
import java.util.logging.SimpleFormatter;
16+
1117
public class PluginLogger {
18+
private static final String LOG_FILE_NAME = "flutter.log";
19+
private static final FileHandler fileHandler;
20+
static {
21+
final String logPath = PathManager.getLogPath();
22+
try {
23+
fileHandler = new FileHandler(logPath + File.separatorChar + LOG_FILE_NAME, 1024 * 1024, 1);
24+
}
25+
catch (IOException e) {
26+
throw new RuntimeException(e);
27+
}
28+
System.setProperty("java.util.logging.SimpleFormatter.format",
29+
"%1$tF %1$tT %3$s [%4$-7s] %5$s %6$s %n");
30+
fileHandler.setFormatter(new SimpleFormatter());
31+
}
32+
1233
public static Logger createLogger(@NotNull Class logClass) {
13-
java.util.logging.Logger.getLogger(logClass.getName()).addHandler(new PluginLogHandler());
34+
java.util.logging.Logger.getLogger(logClass.getName()).addHandler(fileHandler);
1435
return Logger.getInstance(logClass.getName());
1536
}
1637
}

0 commit comments

Comments
 (0)