mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-24 08:35:08 +00:00
pipeline: escape log command line
This commit is contained in:
parent
3640f899f1
commit
4172308cd9
@ -378,11 +378,8 @@ bool indexer_Parse(SemaManager *completion, WorkingFiles *wfiles,
|
|||||||
(Twine(deleted ? "delete " : "parse ") + path_to_index).toVector(msg);
|
(Twine(deleted ? "delete " : "parse ") + path_to_index).toVector(msg);
|
||||||
if (n_errs)
|
if (n_errs)
|
||||||
msg += " error:" + std::to_string(n_errs) + ' ' + first_error;
|
msg += " error:" + std::to_string(n_errs) + ' ' + first_error;
|
||||||
if (LOG_V_ENABLED(1)) {
|
if (LOG_V_ENABLED(1))
|
||||||
msg += "\n ";
|
msg += "\n " + escapeArgs(entry.args);
|
||||||
for (const char *arg : entry.args)
|
|
||||||
(msg += ' ') += arg;
|
|
||||||
}
|
|
||||||
LOG_S(INFO) << std::string_view(msg.data(), msg.size());
|
LOG_S(INFO) << std::string_view(msg.data(), msg.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +59,20 @@ std::pair<LanguageId, bool> lookupExtension(std::string_view filename) {
|
|||||||
return {ret, header};
|
return {ret, header};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string escapeArgs(const std::vector<const char *> &args) {
|
||||||
|
std::string ret;
|
||||||
|
for (const char *arg_c : args) {
|
||||||
|
if (ret.size())
|
||||||
|
ret += ' ';
|
||||||
|
std::string_view arg(arg_c);
|
||||||
|
if (arg.find_first_of("\"()<>") != std::string::npos)
|
||||||
|
((ret += "'") += arg) += "'";
|
||||||
|
else
|
||||||
|
ret += arg;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
enum OptionClass {
|
enum OptionClass {
|
||||||
|
@ -16,6 +16,7 @@ namespace ccls {
|
|||||||
struct WorkingFiles;
|
struct WorkingFiles;
|
||||||
|
|
||||||
std::pair<LanguageId, bool> lookupExtension(std::string_view filename);
|
std::pair<LanguageId, bool> lookupExtension(std::string_view filename);
|
||||||
|
std::string escapeArgs(const std::vector<const char *> &args);
|
||||||
|
|
||||||
struct Project {
|
struct Project {
|
||||||
struct Entry {
|
struct Entry {
|
||||||
|
@ -768,11 +768,8 @@ SemaManager::ensureSession(const std::string &path, bool *created) {
|
|||||||
session = std::make_shared<ccls::Session>(
|
session = std::make_shared<ccls::Session>(
|
||||||
project_->findEntry(path, false, false), wfiles, pch);
|
project_->findEntry(path, false, false), wfiles, pch);
|
||||||
std::string line;
|
std::string line;
|
||||||
if (LOG_V_ENABLED(1)) {
|
if (LOG_V_ENABLED(1))
|
||||||
line = "\n ";
|
line = "\n " + escapeArgs(session->file.args);
|
||||||
for (auto &arg : session->file.args)
|
|
||||||
(line += ' ') += arg;
|
|
||||||
}
|
|
||||||
LOG_S(INFO) << "create session for " << path << line;
|
LOG_S(INFO) << "create session for " << path << line;
|
||||||
sessions.insert(path, session);
|
sessions.insert(path, session);
|
||||||
if (created)
|
if (created)
|
||||||
|
Loading…
Reference in New Issue
Block a user