mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Add braces to C++ single-line loops and conditionals (NFC) (#2973)
This makes code easier to read and more consistent between C++ and Java. Also update clang-format settings to always add a line break (even if no braces are used).
This commit is contained in:
@@ -22,21 +22,24 @@ static void DefaultLogger(unsigned int level, const char* file,
|
||||
}
|
||||
|
||||
wpi::StringRef levelmsg;
|
||||
if (level >= 50)
|
||||
if (level >= 50) {
|
||||
levelmsg = "CRITICAL: ";
|
||||
else if (level >= 40)
|
||||
} else if (level >= 40) {
|
||||
levelmsg = "ERROR: ";
|
||||
else if (level >= 30)
|
||||
} else if (level >= 30) {
|
||||
levelmsg = "WARNING: ";
|
||||
else
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
oss << "NT: " << levelmsg << msg << " (" << file << ':' << line << ")\n";
|
||||
wpi::errs() << oss.str();
|
||||
}
|
||||
|
||||
LoggerImpl::LoggerImpl(int inst) : m_inst(inst) {}
|
||||
|
||||
void LoggerImpl::Start() { DoStart(m_inst); }
|
||||
void LoggerImpl::Start() {
|
||||
DoStart(m_inst);
|
||||
}
|
||||
|
||||
unsigned int LoggerImpl::Add(
|
||||
std::function<void(const LogMessage& msg)> callback, unsigned int min_level,
|
||||
@@ -52,11 +55,15 @@ unsigned int LoggerImpl::AddPolled(unsigned int poller_uid,
|
||||
|
||||
unsigned int LoggerImpl::GetMinLevel() {
|
||||
auto thr = GetThread();
|
||||
if (!thr) return NT_LOG_INFO;
|
||||
if (!thr) {
|
||||
return NT_LOG_INFO;
|
||||
}
|
||||
unsigned int level = NT_LOG_INFO;
|
||||
for (size_t i = 0; i < thr->m_listeners.size(); ++i) {
|
||||
const auto& listener = thr->m_listeners[i];
|
||||
if (listener && listener.min_level < level) level = listener.min_level;
|
||||
if (listener && listener.min_level < level) {
|
||||
level = listener.min_level;
|
||||
}
|
||||
}
|
||||
return level;
|
||||
}
|
||||
@@ -67,8 +74,9 @@ void LoggerImpl::Log(unsigned int level, const char* file, unsigned int line,
|
||||
const char* filename = wpi::sys::path::filename(file).data();
|
||||
{
|
||||
auto thr = GetThread();
|
||||
if (!thr || thr->m_listeners.empty())
|
||||
if (!thr || thr->m_listeners.empty()) {
|
||||
DefaultLogger(level, filename, line, msg);
|
||||
}
|
||||
}
|
||||
Send(UINT_MAX, 0, level, filename, line, msg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user