logging/format: use std::format_string to catch formatting string errors at compile time (#3377)

* fix(log): use constexpr format string

* deprecate getFormat
This commit is contained in:
memchr
2023-09-20 07:26:20 +00:00
committed by GitHub
parent d8d0cd75c2
commit 6594b50e57
15 changed files with 130 additions and 171 deletions

View File

@@ -1097,7 +1097,7 @@ void CConfigManager::updateBlurredLS(const std::string& name, const bool forceBl
for (auto& lsl : m->m_aLayerSurfaceLayers) {
for (auto& ls : lsl) {
if (BYADDRESS) {
if (getFormat("0x{:x}", (uintptr_t)ls.get()) == matchName)
if (std::format("0x{:x}", (uintptr_t)ls.get()) == matchName)
ls->forceBlur = forceBlur;
} else if (ls->szNamespace == matchName)
ls->forceBlur = forceBlur;
@@ -1206,7 +1206,7 @@ void CConfigManager::handleSource(const std::string& command, const std::string&
if (auto r = glob(absolutePath(rawpath, configCurrentPath).c_str(), GLOB_TILDE, nullptr, glob_buf.get()); r != 0) {
parseError = std::format("source= globbing error: {}", r == GLOB_NOMATCH ? "found no match" : GLOB_ABORTED ? "read error" : "out of memory");
Debug::log(ERR, parseError);
Debug::log(ERR, "{}", parseError);
return;
}
@@ -1942,7 +1942,7 @@ std::vector<SLayerRule> CConfigManager::getMatchingRules(SLayerSurface* pLS) {
for (auto& lr : m_dLayerRules) {
if (lr.targetNamespace.find("address:0x") == 0) {
if (getFormat("address:0x{:x}", (uintptr_t)pLS) != lr.targetNamespace)
if (std::format("address:0x{:x}", (uintptr_t)pLS) != lr.targetNamespace)
continue;
} else {
std::regex NSCHECK(lr.targetNamespace);