Skip to content

Commit

Permalink
test: disable completely logging for tests in release
Browse files Browse the repository at this point in the history
Also when running the tst_knut.

Change-Id: I56f7fa34d45cd2236511427546130dd1d006717e
  • Loading branch information
narnaud authored and LeonMatthesKDAB committed Jun 10, 2024
1 parent bfe826f commit 495af45
Show file tree
Hide file tree
Showing 48 changed files with 267 additions and 211 deletions.
2 changes: 1 addition & 1 deletion src/core/classsymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ QVector<Symbol *> ClassSymbol::findMembers() const
}
return members;
}
spdlog::warn("Parent of CppClass {} is not an CodeDocument!", m_name);
WARN("Parent of CppClass {} is not an CodeDocument!", m_name);
return {};
}

Expand Down
33 changes: 16 additions & 17 deletions src/core/codedocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ std::pair<QString, std::optional<TextRange>> CodeDocument::hoverWithRange(
if (const auto *content = std::get_if<Lsp::MarkupContent>(&hover.contents)) {
return {QString::fromStdString(content->value), range};
} else {
spdlog::warn("LSP returned deprecated MarkedString type which is unsupported by Knut\n - Consider updating "
"your LSP server");
WARN("LSP returned deprecated MarkedString type which is unsupported by Knut\n - Consider updating "
"your LSP server");
return {"", {}};
}
};
Expand All @@ -252,7 +252,7 @@ std::pair<QString, std::optional<TextRange>> CodeDocument::hoverWithRange(
// a Tooltip is requested.
// See: TextView::eventFilter.
if (!std::holds_alternative<Lsp::Hover>(result.value())) {
spdlog::debug("LSP server returned no result for Hover");
DEBUG("LSP server returned no result for Hover");
}
return convertResult(result.value());
}
Expand All @@ -279,10 +279,10 @@ Core::TextLocationList CodeDocument::references(int position) const
if (const auto *locations = std::get_if<std::vector<Lsp::Location>>(&value)) {
return TextLocation::fromLsp(*locations);
} else {
spdlog::warn("CodeDocument::references: Language server returned unsupported references type!");
WARN("CodeDocument::references: Language server returned unsupported references type!");
}
} else {
spdlog::warn("CodeDocument::references: LSP call to references returned nothing!");
WARN("CodeDocument::references: LSP call to references returned nothing!");
}

return textLocations;
Expand Down Expand Up @@ -347,7 +347,7 @@ Document *CodeDocument::followSymbol(int pos)
return nullptr;

if (locations.size() > 1)
spdlog::warn("CodeDocument::followSymbol: Multiple locations returned!");
WARN("CodeDocument::followSymbol: Multiple locations returned!");
// Heuristic: If multiple locations were found, use the last one.
auto location = locations.back();

Expand All @@ -363,8 +363,7 @@ Document *CodeDocument::followSymbol(int pos)
if (codeDocument) {
codeDocument->selectRange(codeDocument->toRange(location.range));
} else {
spdlog::warn("CodeDocument::followSymbol: Opened document '{}' is not an CodeDocument",
document->fileName());
WARN("CodeDocument::followSymbol: Opened document '{}' is not an CodeDocument", document->fileName());
}
}

Expand All @@ -387,7 +386,7 @@ Document *CodeDocument::switchDeclarationDefinition()
});

if (!currentFunction) {
spdlog::info("CodeDocument::switchDeclarationDefinition: Cursor is currently not within a function!");
INFO("CodeDocument::switchDeclarationDefinition: Cursor is currently not within a function!");
return nullptr;
}

Expand Down Expand Up @@ -601,17 +600,17 @@ Core::QueryMatchList CodeDocument::queryInRange(const Core::RangeMark &range, co
LOG("CodeDocument::queryInRange", LOG_ARG("range", range), LOG_ARG("query", query));

if (!range.isValid()) {
spdlog::warn("CodeDocument::queryInRange: Range is not valid");
WARN("CodeDocument::queryInRange: Range is not valid");
return {};
}

const auto nodes = m_treeSitterHelper->nodesInRange(range);

if (nodes.isEmpty()) {
spdlog::warn("CodeDocument::queryInRange: No nodes in range");
WARN("CodeDocument::queryInRange: No nodes in range");
return {};
}
spdlog::debug("CodeDocument::queryInRange: Found {} nodes in range", nodes.size());
DEBUG("CodeDocument::queryInRange: Found {} nodes in range", nodes.size());

auto tsQuery = m_treeSitterHelper->constructQuery(query);
if (!tsQuery)
Expand All @@ -638,7 +637,7 @@ bool CodeDocument::checkClient() const
{
Q_ASSERT(textEdit());
if (!client()) {
spdlog::error("CodeDocument {} has no LSP client - API not available", fileName());
ERROR("CodeDocument {} has no LSP client - API not available", fileName());
return false;
}
return true;
Expand All @@ -653,14 +652,14 @@ void CodeDocument::changeContentLsp(int position, int charsRemoved, int charsAdd
// TODO: Keep copy of previous string around, so we can find the oldEndPosition.
// const auto document = textEdit()->document();
// const auto startblock = document->findBlock(position);
// spdlog::warn("start point: {}, {}", startblock.blockNumber(), position - startblock.position());
// WARN("start point: {}, {}", startblock.blockNumber(), position - startblock.position());

// const auto newEndPosition = position + charsAdded;
// const auto newEndBlock = document->findBlock(newEndPosition);
// spdlog::warn("new end point: {}, {}", newEndBlock.blockNumber(), newEndPosition - newEndBlock.position());
// WARN("new end point: {}, {}", newEndBlock.blockNumber(), newEndPosition - newEndBlock.position());

// const auto plain = document->toPlainText();
// spdlog::warn("added: {}", plain.sliced(position, charsAdded));
// WARN("added: {}", plain.sliced(position, charsAdded));

if (!checkClient()) {
return;
Expand Down Expand Up @@ -694,7 +693,7 @@ void CodeDocument::changeContentLsp(int position, int charsRemoved, int charsAdd

client()->didChange(std::move(params));
} else {
spdlog::error("LSP server does not support Document changes!");
ERROR("LSP server does not support Document changes!");
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/core/codedocument_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ std::optional<treesitter::Tree> &TreeSitterHelper::syntaxTree()
if (!m_tree) {
m_tree = parser().parseString(m_document->text());
if (!m_tree) {
spdlog::warn("CodeDocument::syntaxTree: Failed to parse document {}!", m_document->fileName());
WARN("CodeDocument::syntaxTree: Failed to parse document {}!", m_document->fileName());
}
}
return m_tree;
Expand All @@ -62,8 +62,8 @@ std::shared_ptr<treesitter::Query> TreeSitterHelper::constructQuery(const QStrin
try {
tsQuery = std::make_shared<treesitter::Query>(parser().language(), query);
} catch (treesitter::Query::Error &error) {
spdlog::error("CodeDocument::constructQuery: Failed to parse query `{}` error: {} at: {}", query,
error.description, error.utf8_offset);
ERROR("CodeDocument::constructQuery: Failed to parse query `{}` error: {} at: {}", query, error.description,
error.utf8_offset);
return {};
}
return tsQuery;
Expand Down
Loading

0 comments on commit 495af45

Please sign in to comment.