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 18e4be616c
commit 8ca0978804
4 changed files with 19 additions and 3 deletions

View File

@ -37,4 +37,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

@ -86,6 +86,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

@ -300,7 +300,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

@ -703,7 +703,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;