Refactor logging

Removed redundant checking of logging type in log_impl* .
This commit is contained in:
Stephen Seo 2019-10-22 19:27:55 +09:00
parent b11d87ca12
commit 0f435613bc

View file

@ -140,60 +140,18 @@ private:
template<typename... Targs> template<typename... Targs>
void log_impl(UDPC_LoggingType type, Targs... args) { // {{{ void log_impl(UDPC_LoggingType type, Targs... args) { // {{{
switch(loggingType.load()) { switch(type) {
case UDPC_LoggingType::UDPC_SILENT:
return;
case UDPC_LoggingType::UDPC_ERROR: case UDPC_LoggingType::UDPC_ERROR:
if(type == UDPC_LoggingType::UDPC_ERROR) { std::cerr << "ERROR: ";
std::cerr << "ERROR: ";
} else {
return;
}
break; break;
case UDPC_LoggingType::UDPC_WARNING: case UDPC_LoggingType::UDPC_WARNING:
switch(type) { std::cerr << "WARN: ";
case UDPC_LoggingType::UDPC_ERROR:
std::cerr << "ERROR: ";
break;
case UDPC_LoggingType::UDPC_WARNING:
std::cerr << "WARNING: ";
break;
default:
return;
}
break; break;
case UDPC_LoggingType::UDPC_VERBOSE: case UDPC_LoggingType::UDPC_VERBOSE:
switch(type) { std::cerr << "VERB: ";
case UDPC_LoggingType::UDPC_ERROR:
std::cerr << "ERROR: ";
break;
case UDPC_LoggingType::UDPC_WARNING:
std::cerr << "WARNING: ";
break;
case UDPC_LoggingType::UDPC_VERBOSE:
std::cerr << "VERBOSE: ";
break;
default:
return;
}
break; break;
case UDPC_LoggingType::UDPC_INFO: case UDPC_LoggingType::UDPC_INFO:
switch(type) { std::cerr << "INFO: ";
case UDPC_LoggingType::UDPC_ERROR:
std::cerr << "ERROR: ";
break;
case UDPC_LoggingType::UDPC_WARNING:
std::cerr << "WARNING: ";
break;
case UDPC_LoggingType::UDPC_VERBOSE:
std::cerr << "VERBOSE: ";
break;
case UDPC_LoggingType::UDPC_INFO:
std::cerr << "INFO: ";
break;
default:
return;
}
break; break;
default: default:
return; return;
@ -208,33 +166,7 @@ private:
template<typename T, typename... Targs> template<typename T, typename... Targs>
void log_impl_next(UDPC_LoggingType type, T value, Targs... args) { // {{{ void log_impl_next(UDPC_LoggingType type, T value, Targs... args) { // {{{
switch(loggingType.load()) { std::cerr << value;
case UDPC_LoggingType::UDPC_SILENT:
return;
case UDPC_LoggingType::UDPC_ERROR:
if(type == UDPC_LoggingType::UDPC_ERROR) {
std::cerr << value;
}
break;
case UDPC_LoggingType::UDPC_WARNING:
if(type == UDPC_LoggingType::UDPC_ERROR || type == UDPC_LoggingType::UDPC_WARNING) {
std::cerr << value;
}
break;
case UDPC_LoggingType::UDPC_VERBOSE:
if(type == UDPC_LoggingType::UDPC_ERROR || type == UDPC_LoggingType::UDPC_WARNING
|| type == UDPC_LoggingType::UDPC_VERBOSE) {
std::cerr << value;
}
break;
case UDPC_LoggingType::UDPC_INFO:
if(type == UDPC_LoggingType::UDPC_ERROR || type == UDPC_LoggingType::UDPC_WARNING
|| type == UDPC_LoggingType::UDPC_VERBOSE
|| type == UDPC_LoggingType::UDPC_INFO) {
std::cerr << value;
}
break;
}
log_impl_next(type, args...); log_impl_next(type, args...);
} // }}} } // }}}