ui: add link to "Record State Collectors" action output

GitOrigin-RevId: 75d09dc642484ad8867eea042a69362d3f585e69
This commit is contained in:
Aleksey Pivovarov
2019-06-13 17:12:13 +03:00
committed by intellij-monorepo-bot
parent bf0380fafa
commit a8536294ea
5 changed files with 36 additions and 6 deletions
@@ -4,17 +4,22 @@ package com.intellij.internal.statistic.actions;
import com.intellij.internal.statistic.eventLog.fus.FeatureUsageLogger;
import com.intellij.internal.statistic.service.fus.collectors.FUStateUsagesLogger;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationAction;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import java.io.File;
public class RecordStateStatisticsEventLogAction extends AnAction {
private static final FUStateUsagesLogger myStatesLogger = new FUStateUsagesLogger();
@@ -29,17 +34,24 @@ public class RecordStateStatisticsEventLogAction extends AnAction {
@Override
public void run(@NotNull ProgressIndicator indicator) {
FeatureUsageLogger.INSTANCE.rollOver();
File logFile = FeatureUsageLogger.INSTANCE.getConfig().getActiveLogFile();
VirtualFile logVFile = logFile != null ? LocalFileSystem.getInstance().findFileByIoFile(logFile) : null;
myStatesLogger.logApplicationStates();
myStatesLogger.logProjectStates(project);
ApplicationManager.getApplication().invokeLater(
() -> showNotification(project, "Finished collecting and recording events")
() -> {
Notification notification = new Notification("FeatureUsageStatistics", "Feature Usage Statistics",
"Finished collecting and recording events", NotificationType.INFORMATION);
if (logVFile != null) {
notification.addAction(NotificationAction.createSimple("Show Log File", () -> {
FileEditorManager.getInstance(project).openFile(logVFile, true);
}));
}
notification.notify(project);
}
);
}
});
}
protected void showNotification(@NotNull Project project, @NotNull String message) {
Notifications.Bus.notify(new Notification("FeatureUsageStatistics", "Feature Usage Statistics", message, NotificationType.INFORMATION), project);
}
}
@@ -14,6 +14,8 @@ import java.nio.file.Paths
interface StatisticsEventLogWriter {
fun log(message: String)
fun getActiveFile(): File?
fun getFiles(): List<File>
fun cleanup()
@@ -58,6 +60,11 @@ class StatisticsEventLogFileWriter(private val recorderId: String, private val m
eventLogger.info(message)
}
override fun getActiveFile(): File? {
val activeLog = fileAppender?.activeLogName ?: return null
return File(File(getEventLogDir().toUri()), activeLog)
}
override fun getFiles(): List<File> {
val activeLog = fileAppender?.activeLogName
val files = File(getEventLogDir().toUri()).listFiles { f: File -> !StringUtil.equals(f.name, activeLog) }
@@ -16,6 +16,7 @@ private val EP_NAME = ExtensionPointName.create<StatisticsEventLoggerProvider>("
interface StatisticsEventLogger {
fun log(group: EventLogGroup, eventId: String, isState: Boolean)
fun log(group: EventLogGroup, eventId: String, data: Map<String, Any>, isState: Boolean)
fun getActiveLogFile(): File?
fun getLogFiles(): List<File>
fun cleanup()
fun rollOver()
@@ -30,6 +31,10 @@ abstract class StatisticsEventLoggerProvider(val recorderId: String,
abstract fun isRecordEnabled() : Boolean
abstract fun isSendEnabled() : Boolean
fun getActiveLogFile(): File? {
return logger.getActiveLogFile()
}
fun getLogFiles(): List<File> {
return logger.getLogFiles()
}
@@ -61,6 +66,7 @@ class EmptyStatisticsEventLoggerProvider(recorderId: String): StatisticsEventLog
class EmptyStatisticsEventLogger : StatisticsEventLogger {
override fun log(group: EventLogGroup, eventId: String, isState: Boolean) = Unit
override fun log(group: EventLogGroup, eventId: String, data: Map<String, Any>, isState: Boolean) = Unit
override fun getActiveLogFile(): File? = null
override fun getLogFiles(): List<File> = emptyList()
override fun cleanup() = Unit
override fun rollOver() = Unit
@@ -68,6 +68,10 @@ open class StatisticsFileEventLogger(private val recorderId: String,
lastEvent = null
}
override fun getActiveLogFile(): File? {
return writer.getActiveFile()
}
override fun getLogFiles(): List<File> {
return writer.getFiles()
}
@@ -321,6 +321,7 @@ class TestFeatureUsageEventWriter : StatisticsEventLogWriter {
logged.add(message)
}
override fun getActiveFile(): File? = null
override fun getFiles(): List<File> = emptyList()
override fun cleanup() = Unit
override fun rollOver() = Unit