mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-24 00:25:07 +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);
|
||||
if (n_errs)
|
||||
msg += " error:" + std::to_string(n_errs) + ' ' + first_error;
|
||||
if (LOG_V_ENABLED(1)) {
|
||||
msg += "\n ";
|
||||
for (const char *arg : entry.args)
|
||||
(msg += ' ') += arg;
|
||||
}
|
||||
if (LOG_V_ENABLED(1))
|
||||
msg += "\n " + escapeArgs(entry.args);
|
||||
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};
|
||||
}
|
||||
|
||||
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 {
|
||||
|
||||
enum OptionClass {
|
||||
|
@ -16,6 +16,7 @@ namespace ccls {
|
||||
struct WorkingFiles;
|
||||
|
||||
std::pair<LanguageId, bool> lookupExtension(std::string_view filename);
|
||||
std::string escapeArgs(const std::vector<const char *> &args);
|
||||
|
||||
struct Project {
|
||||
struct Entry {
|
||||
|
@ -768,11 +768,8 @@ SemaManager::ensureSession(const std::string &path, bool *created) {
|
||||
session = std::make_shared<ccls::Session>(
|
||||
project_->findEntry(path, false, false), wfiles, pch);
|
||||
std::string line;
|
||||
if (LOG_V_ENABLED(1)) {
|
||||
line = "\n ";
|
||||
for (auto &arg : session->file.args)
|
||||
(line += ' ') += arg;
|
||||
}
|
||||
if (LOG_V_ENABLED(1))
|
||||
line = "\n " + escapeArgs(session->file.args);
|
||||
LOG_S(INFO) << "create session for " << path << line;
|
||||
sessions.insert(path, session);
|
||||
if (created)
|
||||
|
Loading…
Reference in New Issue
Block a user