Log {Request,Notification}Message, and timestamp change due to dependency

This commit is contained in:
Fangrui Song 2019-01-29 15:47:03 +08:00
parent d4de474be1
commit f1efcb80c7
2 changed files with 17 additions and 5 deletions

View File

@ -49,7 +49,8 @@ namespace {
OptionCategory C("ccls options");
opt<bool> opt_help("h", desc("Alias for -help"), cat(C));
opt<int> opt_verbose("v", desc("verbosity"), init(0), cat(C));
opt<int> opt_verbose("v", desc("verbosity, from -3 (fatal) to 2 (verbose)"),
init(0), cat(C));
opt<std::string> opt_test_index("test-index", ValueOptional, init("!"),
desc("run index tests"), cat(C));

View File

@ -118,8 +118,8 @@ bool CacheInvalid(VFS *vfs, IndexFile *prev, const std::string &path,
{
std::lock_guard<std::mutex> lock(vfs->mutex);
if (prev->mtime < vfs->state[path].timestamp) {
LOG_S(INFO) << "timestamp changed for " << path
<< (from ? " (via " + *from + ")" : std::string());
LOG_V(1) << "timestamp changed for " << path
<< (from ? " (via " + *from + ")" : std::string());
return true;
}
}
@ -131,8 +131,8 @@ bool CacheInvalid(VFS *vfs, IndexFile *prev, const std::string &path,
if (strcmp(prev->args[i], args[i]) && sys::path::stem(args[i]) != stem)
changed = true;
if (changed)
LOG_S(INFO) << "args changed for " << path
<< (from ? " (via " + *from + ")" : std::string());
LOG_V(1) << "args changed for " << path
<< (from ? " (via " + *from + ")" : std::string());
return changed;
};
@ -262,10 +262,14 @@ bool Indexer_Parse(SemaManager *completion, WorkingFiles *wfiles,
if (auto mtime1 = LastWriteTime(dep.first.val().str())) {
if (dep.second < *mtime1) {
reparse = 2;
LOG_V(1) << "timestamp changed for " << path_to_index << " via "
<< dep.first.val().str();
break;
}
} else {
reparse = 2;
LOG_V(1) << "timestamp changed for " << path_to_index << " via "
<< dep.first.val().str();
break;
}
}
@ -525,6 +529,10 @@ void LaunchStdin() {
std::string method;
ReflectMember(reader, "id", id);
ReflectMember(reader, "method", method);
if (id.Valid())
LOG_V(2) << "receive RequestMessage: " << id.value << " " << method;
else
LOG_V(2) << "receive NotificationMessage " << method;
if (method.empty())
continue;
bool should_exit = method == "exit";
@ -738,6 +746,7 @@ void NotifyOrRequest(const char *method, bool request,
JsonWriter writer(&w);
fn(writer);
w.EndObject();
LOG_V(2) << (request ? "RequestMessage: " : "NotificationMessage: ") << method;
for_stdout->PushBack(output.GetString());
}
@ -765,6 +774,8 @@ static void Reply(RequestId id, const char *key,
JsonWriter writer(&w);
fn(writer);
w.EndObject();
if (id.Valid())
LOG_V(2) << "respond to RequestMessage: " << id.value;
for_stdout->PushBack(output.GetString());
}