Make -v=1 work and log cflags for SemaManager session and Indexer

This commit is contained in:
Fangrui Song 2018-12-21 18:23:35 -08:00
parent 808aa120d1
commit 79732bf375
4 changed files with 19 additions and 3 deletions

View File

@ -40,4 +40,5 @@ struct Message {
#define LOG_IF_S(v, cond) \ #define LOG_IF_S(v, cond) \
LOG_IF(ccls::log::Verbosity_##v, \ LOG_IF(ccls::log::Verbosity_##v, \
(cond) && ccls::log::Verbosity_##v <= ccls::log::verbosity) (cond) && ccls::log::Verbosity_##v <= ccls::log::verbosity)
#define LOG_V(v) LOG_IF(ccls::log::Verbosity(v), v <= ccls::log::verbosity) #define LOG_V_ENABLED(v) (v <= ccls::log::verbosity)
#define LOG_V(v) LOG_IF(ccls::log::Verbosity(v), LOG_V_ENABLED(v))

View File

@ -74,6 +74,7 @@ int main(int argc, char **argv) {
PrintHelpMessage(); PrintHelpMessage();
return 0; return 0;
} }
ccls::log::verbosity = ccls::log::Verbosity(opt_verbose.getValue());
pipeline::Init(); pipeline::Init();
const char *env = getenv("CCLS_CRASH_RECOVERY"); const char *env = getenv("CCLS_CRASH_RECOVERY");

View File

@ -288,7 +288,15 @@ bool Indexer_Parse(SemaManager *completion, WorkingFiles *wfiles,
return true; return true;
} while (0); } while (0);
LOG_IF_S(INFO, loud) << "parse " << path_to_index; if (loud) {
std::string line;
if (LOG_V_ENABLED(1)) {
line = "\n ";
for (auto &arg : entry.args)
(line += ' ') += arg;
}
LOG_S(INFO) << "parse " << path_to_index << line;
}
std::vector<std::pair<std::string, std::string>> remapped; std::vector<std::pair<std::string, std::string>> remapped;
if (g_config->index.onChange) { if (g_config->index.onChange) {

View File

@ -692,7 +692,13 @@ SemaManager::EnsureSession(const std::string &path, bool *created) {
if (!session) { if (!session) {
session = std::make_shared<ccls::Session>( session = std::make_shared<ccls::Session>(
project_->FindEntry(path, false), wfiles, PCH); project_->FindEntry(path, false), wfiles, PCH);
LOG_S(INFO) << "create session for " << path; std::string line;
if (LOG_V_ENABLED(1)) {
line = "\n ";
for (auto &arg : session->file.args)
(line += ' ') += arg;
}
LOG_S(INFO) << "create session for " << path << line;
sessions.Insert(path, session); sessions.Insert(path, session);
if (created) if (created)
*created = true; *created = true;