mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-11-03 22:04:24 +00:00 
			
		
		
		
	Reduce STDERR logging to only WARNING and above.
INFO logs are now only viewable in the log file, which is not written by default. A new command line option --log-file can be used to control where the log file is written. INFO logs can be written to STDERR if --log-all-to-stderr is passed.
This commit is contained in:
		
							parent
							
								
									0e4148518a
								
							
						
					
					
						commit
						3b9371f4b5
					
				@ -986,11 +986,14 @@ void LanguageServerMain(const std::string& bin_name,
 | 
				
			|||||||
// MAIN ////////////////////////////////////////////////////////////////////////
 | 
					// MAIN ////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
////////////////////////////////////////////////////////////////////////////////
 | 
					////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
int main(int argc, char** argv) {
 | 
					int main(int argc, char** argv) {
 | 
				
			||||||
  loguru::init(argc, argv);
 | 
					  std::unordered_map<std::string, std::string> options =
 | 
				
			||||||
  loguru::add_file("cquery_diagnostics.log", loguru::Truncate,
 | 
					      ParseOptions(argc, argv);
 | 
				
			||||||
                   loguru::Verbosity_MAX);
 | 
					
 | 
				
			||||||
 | 
					  if (!HasOption(options, "--log-all-to-stderr"))
 | 
				
			||||||
 | 
					    loguru::g_stderr_verbosity = loguru::Verbosity_WARNING;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  loguru::g_flush_interval_ms = 0;
 | 
					  loguru::g_flush_interval_ms = 0;
 | 
				
			||||||
  loguru::g_stderr_verbosity = 1;
 | 
					  loguru::init(argc, argv);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  MultiQueueWaiter waiter;
 | 
					  MultiQueueWaiter waiter;
 | 
				
			||||||
  IpcManager::CreateInstance(&waiter);
 | 
					  IpcManager::CreateInstance(&waiter);
 | 
				
			||||||
@ -1003,19 +1006,21 @@ int main(int argc, char** argv) {
 | 
				
			|||||||
  PlatformInit();
 | 
					  PlatformInit();
 | 
				
			||||||
  IndexInit();
 | 
					  IndexInit();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  std::unordered_map<std::string, std::string> options =
 | 
					 | 
				
			||||||
      ParseOptions(argc, argv);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  bool print_help = true;
 | 
					  bool print_help = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (HasOption(options, "--log-file")) {
 | 
				
			||||||
 | 
					    loguru::add_file(options["--log-file"].c_str(), loguru::Truncate,
 | 
				
			||||||
 | 
					                     loguru::Verbosity_MAX);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (HasOption(options, "--log-stdin-stdout-to-stderr"))
 | 
				
			||||||
 | 
					    g_log_stdin_stdout_to_stderr = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (HasOption(options, "--clang-sanity-check")) {
 | 
					  if (HasOption(options, "--clang-sanity-check")) {
 | 
				
			||||||
    print_help = false;
 | 
					    print_help = false;
 | 
				
			||||||
    ClangSanityCheck();
 | 
					    ClangSanityCheck();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (HasOption(options, "--log-stdin-stdout-to-stderr"))
 | 
					 | 
				
			||||||
    g_log_stdin_stdout_to_stderr = true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (HasOption(options, "--test-unit")) {
 | 
					  if (HasOption(options, "--test-unit")) {
 | 
				
			||||||
    print_help = false;
 | 
					    print_help = false;
 | 
				
			||||||
    doctest::Context context;
 | 
					    doctest::Context context;
 | 
				
			||||||
@ -1043,36 +1048,40 @@ int main(int argc, char** argv) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (print_help) {
 | 
					  if (print_help) {
 | 
				
			||||||
    std::cout << R"help(cquery help:
 | 
					    std::cout << R"help(cquery is a low-latency C++ language server.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  cquery is a low-latency C++ language server.
 | 
					Command line options:
 | 
				
			||||||
 | 
					 | 
				
			||||||
  General:
 | 
					 | 
				
			||||||
    --help        Print this help information.
 | 
					 | 
				
			||||||
  --language-server
 | 
					  --language-server
 | 
				
			||||||
                  Run as a language server. This implements the language
 | 
					                Run as a language server. This implements the language server
 | 
				
			||||||
                  server spec over STDIN and STDOUT.
 | 
					                spec over STDIN and STDOUT.
 | 
				
			||||||
  --test-unit   Run unit tests.
 | 
					  --test-unit   Run unit tests.
 | 
				
			||||||
  --test-index  Run index tests.
 | 
					  --test-index  Run index tests.
 | 
				
			||||||
  --log-stdin-stdout-to-stderr
 | 
					  --log-stdin-stdout-to-stderr
 | 
				
			||||||
                Print stdin and stdout messages to stderr. This is a aid for
 | 
					                Print stdin and stdout messages to stderr. This is a aid for
 | 
				
			||||||
                  developing new language clients, as it makes it easier to
 | 
					                developing new language clients, as it makes it easier to figure
 | 
				
			||||||
                  figure out how the client is interacting with cquery.
 | 
					                out how the client is interacting with cquery.
 | 
				
			||||||
 | 
					  --log-file <absoulte_path>
 | 
				
			||||||
 | 
					                Emit diagnostic logging to the given path, which is taken
 | 
				
			||||||
 | 
					                literally, ie, it will be relative to the current working
 | 
				
			||||||
 | 
					                directory.
 | 
				
			||||||
 | 
					  --log-all-to-stderr
 | 
				
			||||||
 | 
					                Write all log messages to STDERR.
 | 
				
			||||||
  --clang-sanity-check
 | 
					  --clang-sanity-check
 | 
				
			||||||
                Run a simple index test. Verifies basic clang functionality.
 | 
					                Run a simple index test. Verifies basic clang functionality.
 | 
				
			||||||
                Needs to be executed from the cquery root checkout directory.
 | 
					                Needs to be executed from the cquery root checkout directory.
 | 
				
			||||||
 | 
					  --help        Print this help information.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Configuration:
 | 
					Configuration:
 | 
				
			||||||
    When opening up a directory, cquery will look for a compile_commands.json
 | 
					  When opening up a directory, cquery will look for a compile_commands.json file
 | 
				
			||||||
    file emitted by your preferred build system. If not present, cquery will
 | 
					  emitted by your preferred build system. If not present, cquery will use a
 | 
				
			||||||
    use a recursive directory listing instead. Command line flags can be
 | 
					  recursive directory listing instead. Command line flags can be provided by
 | 
				
			||||||
    provided by adding a file named `.cquery` in the top-level directory. Each
 | 
					  adding a file named `.cquery` in the top-level directory. Each line in that
 | 
				
			||||||
    line in that file is a separate argument.
 | 
					  file is a separate argument.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    There are also a number of configuration options available when
 | 
					  There are also a number of configuration options available when initializing
 | 
				
			||||||
    initializing the language server - your editor should have tooling to
 | 
					  the language server - your editor should have tooling to describe those
 | 
				
			||||||
    describe those options. See |Config| in this source code for a detailed
 | 
					  options.  See |Config| in this source code for a detailed list of all
 | 
				
			||||||
    list of all currently supported options.
 | 
					  currently supported options.
 | 
				
			||||||
)help";
 | 
					)help";
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user