mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-24 08:35:08 +00:00
Add -log-file=stderr and make it default
Change -log-file-append to a boolean flag
This commit is contained in:
parent
d6329ea328
commit
26fb0a9dd3
@ -72,6 +72,7 @@ Message::~Message() {
|
|||||||
std::lock_guard<std::mutex> lock(mtx);
|
std::lock_guard<std::mutex> lock(mtx);
|
||||||
stream_ << '\n';
|
stream_ << '\n';
|
||||||
fputs(stream_.str().c_str(), file);
|
fputs(stream_.str().c_str(), file);
|
||||||
|
fflush(file);
|
||||||
if (verbosity_ == Verbosity_FATAL)
|
if (verbosity_ == Verbosity_FATAL)
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
19
src/main.cc
19
src/main.cc
@ -58,10 +58,10 @@ opt<std::string> opt_index("index",
|
|||||||
value_desc("root"), cat(C));
|
value_desc("root"), cat(C));
|
||||||
list<std::string> opt_init("init", desc("extra initialization options in JSON"),
|
list<std::string> opt_init("init", desc("extra initialization options in JSON"),
|
||||||
cat(C));
|
cat(C));
|
||||||
opt<std::string> opt_log_file("log-file", desc("log"), value_desc("filename"),
|
opt<std::string> opt_log_file("log-file", desc("stderr or log file"),
|
||||||
|
value_desc("file"), init("stderr"), cat(C));
|
||||||
|
opt<bool> opt_log_file_append("log-file-append", desc("append to log file"),
|
||||||
cat(C));
|
cat(C));
|
||||||
opt<std::string> opt_log_file_append("log-file-append", desc("log"),
|
|
||||||
value_desc("filename"), cat(C));
|
|
||||||
|
|
||||||
void CloseLog() { fclose(ccls::log::file); }
|
void CloseLog() { fclose(ccls::log::file); }
|
||||||
|
|
||||||
@ -95,14 +95,13 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
bool language_server = true;
|
bool language_server = true;
|
||||||
|
|
||||||
if (opt_log_file.size() || opt_log_file_append.size()) {
|
if (opt_log_file.size()) {
|
||||||
ccls::log::file = opt_log_file.size()
|
ccls::log::file =
|
||||||
? fopen(opt_log_file.c_str(), "wb")
|
opt_log_file == "stderr"
|
||||||
: fopen(opt_log_file_append.c_str(), "ab");
|
? stderr
|
||||||
|
: fopen(opt_log_file.c_str(), opt_log_file_append ? "ab" : "wb");
|
||||||
if (!ccls::log::file) {
|
if (!ccls::log::file) {
|
||||||
fprintf(
|
fprintf(stderr, "failed to open %s\n", opt_log_file.c_str());
|
||||||
stderr, "failed to open %s\n",
|
|
||||||
(opt_log_file.size() ? opt_log_file : opt_log_file_append).c_str());
|
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
setbuf(ccls::log::file, NULL);
|
setbuf(ccls::log::file, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user