Merge branch 'ms311' into 'branch-0.4.0'

MS-311 1. error log remove compile address

See merge request megasearch/milvus!543

Former-commit-id: 21094596ab39654d5f3ba9ac460bfc3e6dbece8e
This commit is contained in:
jinhai 2019-09-10 20:16:06 +08:00
commit 5c8225adfd

View File

@ -14,11 +14,23 @@ namespace knowhere {
KnowhereException::KnowhereException(const std::string &msg):msg(msg) {}
KnowhereException::KnowhereException(const std::string &m, const char *funcName, const char *file, int line) {
#ifdef DEBUG
int size = snprintf(nullptr, 0, "Error in %s at %s:%d: %s",
funcName, file, line, m.c_str());
msg.resize(size + 1);
snprintf(&msg[0], msg.size(), "Error in %s at %s:%d: %s",
funcName, file, line, m.c_str());
#else
std::string file_path(file);
auto const pos = file_path.find_last_of('/');
auto filename = file_path.substr(pos+1).c_str();
int size = snprintf(nullptr, 0, "Error in %s at %s:%d: %s",
funcName, filename, line, m.c_str());
msg.resize(size + 1);
snprintf(&msg[0], msg.size(), "Error in %s at %s:%d: %s",
funcName, filename, line, m.c_str());
#endif
}
const char *KnowhereException::what() const noexcept {