From 8ca0978804618a5f3797e8c07c99e5b46564cb79 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Fri, 21 Dec 2018 18:23:35 -0800 Subject: [PATCH] Make -v=1 work and log cflags for SemaManager session and Indexer --- src/log.hh | 3 ++- src/main.cc | 1 + src/pipeline.cc | 10 +++++++++- src/sema_manager.cc | 8 +++++++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/log.hh b/src/log.hh index 64fc63d6..5d06d41a 100644 --- a/src/log.hh +++ b/src/log.hh @@ -37,4 +37,5 @@ struct Message { #define LOG_IF_S(v, cond) \ LOG_IF(ccls::log::Verbosity_##v, \ (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)) diff --git a/src/main.cc b/src/main.cc index 43930298..95cd0363 100644 --- a/src/main.cc +++ b/src/main.cc @@ -86,6 +86,7 @@ int main(int argc, char **argv) { PrintHelpMessage(); return 0; } + ccls::log::verbosity = ccls::log::Verbosity(opt_verbose.getValue()); pipeline::Init(); const char *env = getenv("CCLS_CRASH_RECOVERY"); diff --git a/src/pipeline.cc b/src/pipeline.cc index 1d84669e..26e57d82 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -300,7 +300,15 @@ bool Indexer_Parse(SemaManager *completion, WorkingFiles *wfiles, return true; } 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> remapped; if (g_config->index.onChange) { diff --git a/src/sema_manager.cc b/src/sema_manager.cc index 194e703d..3d969b36 100644 --- a/src/sema_manager.cc +++ b/src/sema_manager.cc @@ -703,7 +703,13 @@ SemaManager::EnsureSession(const std::string &path, bool *created) { if (!session) { session = std::make_shared( 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); if (created) *created = true;