IDEA-104784 (diagnostic)

This commit is contained in:
Roman Shevchenko
2013-04-15 21:40:15 +02:00
parent 1f5e82ec3b
commit f7b23a66e3
5 changed files with 19 additions and 14 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -36,14 +36,14 @@
#define LOG_ENV_ERROR "error"
#define LOG_ENV_OFF "off"
#define VERSION "1.2"
#define VERSION "20130415.2136"
#define VERSION_MSG "fsnotifier " VERSION "\n"
#define USAGE_MSG \
"fsnotifier - IntelliJ IDEA companion program for watching and reporting file and directory structure modifications.\n\n" \
"fsnotifier utilizes \"user\" facility of syslog(3) - messages usually can be found in /var/log/user.log.\n" \
"Verbosity is regulated via " LOG_ENV " environment variable, possible values are: " \
LOG_ENV_DEBUG ", " LOG_ENV_INFO ", " LOG_ENV_WARNING ", " LOG_ENV_ERROR ", " LOG_ENV_OFF "; latter is the default.\n\n" \
LOG_ENV_DEBUG ", " LOG_ENV_INFO ", " LOG_ENV_WARNING ", " LOG_ENV_ERROR ", " LOG_ENV_OFF "; default is " LOG_ENV_WARNING ".\n\n" \
"Use 'fsnotifier --selftest' to perform some self-diagnostics (output will be logged and printed to console).\n"
#define HELP_MSG \
@@ -142,8 +142,9 @@ int main(int argc, char** argv) {
static void init_log() {
int level = LOG_WARNING;
char* env_level = getenv(LOG_ENV);
int level = LOG_EMERG;
if (env_level != NULL) {
if (strcmp(env_level, LOG_ENV_DEBUG) == 0) level = LOG_DEBUG;
else if (strcmp(env_level, LOG_ENV_INFO) == 0) level = LOG_INFO;
@@ -350,13 +351,13 @@ static bool register_roots(array* new_roots, array* unwatchable, array* mounts)
for (int j=0; j<array_size(mounts); j++) {
char* mount = array_get(mounts, j);
if (is_parent_path(mount, unflattened)) {
userlog(LOG_DEBUG, "watch root '%s' is under mount point '%s' - skipping", unflattened, mount);
userlog(LOG_INFO, "watch root '%s' is under mount point '%s' - skipping", unflattened, mount);
CHECK_NULL(array_push(unwatchable, strdup(unflattened)), false);
skip = true;
break;
}
else if (is_parent_path(unflattened, mount)) {
userlog(LOG_DEBUG, "watch root '%s' contains mount point '%s' - partial watch", unflattened, mount);
userlog(LOG_INFO, "watch root '%s' contains mount point '%s' - partial watch", unflattened, mount);
char* copy = strdup(mount);
CHECK_NULL(array_push(unwatchable, copy), false);
CHECK_NULL(array_push(inner_mounts, copy), false);
@@ -381,6 +382,7 @@ static bool register_roots(array* new_roots, array* unwatchable, array* mounts)
return false;
}
else if (id != ERR_IGNORE) {
userlog(LOG_WARNING, "watch root '%s' cannot be watched: %d", unflattened, id);
CHECK_NULL(array_push(unwatchable, strdup(unflattened)), false);
}
}

View File

@@ -33,12 +33,14 @@ import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.startup.StartupActivity;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.vfs.impl.local.FileWatcher;
import com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl;
import com.intellij.openapi.vfs.newvfs.RefreshQueue;
import com.intellij.util.SmartList;
import com.intellij.util.io.storage.HeavyProcessLatch;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.ui.UIUtil;
@@ -219,23 +221,23 @@ public class StartupManagerImpl extends StartupManagerEx {
VirtualFile[] roots = ProjectRootManager.getInstance(myProject).getContentRoots();
if (roots.length == 0) return;
boolean nonWatched = false;
loop:
List<String> nonWatched = new SmartList<String>();
for (VirtualFile root : roots) {
if (!(root.getFileSystem() instanceof LocalFileSystem)) continue;
String rootPath = root.getPath();
for (String manualWatchRoot : manualWatchRoots) {
if (FileUtil.isAncestor(manualWatchRoot, rootPath, false)) {
LOG.info("'" + root + "' is under manual watch root '" + manualWatchRoot + "', others are " + manualWatchRoot);
nonWatched = true;
break loop;
nonWatched.add(rootPath);
}
}
}
if (nonWatched) {
if (!nonWatched.isEmpty()) {
LOG.info("unwatched roots: " + nonWatched);
LOG.info("manual watches: " + manualWatchRoots);
String title = ApplicationBundle.message("watcher.slow.sync");
String message = ApplicationBundle.message("watcher.non.watchable.project");
StringUtil.join(nonWatched, "<br>");
Notifications.Bus.notify(FileWatcher.NOTIFICATION_GROUP.getValue().createNotification(title, message, NotificationType.WARNING, null));
}
}

View File

@@ -475,9 +475,10 @@ public class FileWatcher {
}
}
else if (myLastOp == WatcherOp.MESSAGE) {
Notifications.Bus.notify(
new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "File Watcher", line, NotificationType.WARNING, NotificationListener.URL_OPENING_LISTENER)
);
LOG.warn(line);
String title = ApplicationBundle.message("watcher.slow.sync");
NotificationListener listener = NotificationListener.URL_OPENING_LISTENER;
Notifications.Bus.notify(NOTIFICATION_GROUP.getValue().createNotification(title, line, NotificationType.WARNING, listener));
myLastOp = null;
}
else if (myLastOp == WatcherOp.REMAP || myLastOp == WatcherOp.UNWATCHEABLE) {