From 3edda5cf76165469668fd097c3655e71879a9d57 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 b01920ad..39a8396a 100644 --- a/src/log.hh +++ b/src/log.hh @@ -40,4 +40,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 536c5df8..37a50f45 100644 --- a/src/main.cc +++ b/src/main.cc @@ -74,6 +74,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 5e1b5a5d..abfbe08f 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -288,7 +288,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 2b2c2c5e..0696414d 100644 --- a/src/sema_manager.cc +++ b/src/sema_manager.cc @@ -692,7 +692,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;