Stacktrace dump method added

Summary: Stacktrace dump method added

Test Plan: manual

Reviewers: buda

Subscribers: buda

Differential Revision: https://memgraph.phacility.com/D19
This commit is contained in:
sale 2016-12-16 14:49:20 +00:00
parent 9154f9b719
commit b4c65d9680
3 changed files with 18 additions and 13 deletions

View File

@ -58,6 +58,22 @@ public:
return lines.size();
}
void dump(std::ostream& stream) {
std::string message;
for (int i = 0; i < size(); i++) {
message.append(fmt::format("at {} ({})\n", lines[i].function,
lines[i].location));
}
stream << message;
}
void dump(std::string& message) {
for (int i = 0; i < size(); i++) {
message.append(fmt::format("at {} ({}) \n", lines[i].function,
lines[i].location));
}
}
private:
std::vector<Line> lines;

View File

@ -9,14 +9,7 @@
// TODO: log to local file or remote database
void stacktrace(std::ostream& stream) noexcept {
Stacktrace stacktrace;
std::string message;
for (int i = 0; i < stacktrace.size(); i++) {
message.append(fmt::format("\n at {} ({})", stacktrace[i].function,
stacktrace[i].location));
}
stream << message << std::endl;
stacktrace.dump(stream);
}
// TODO: log to local file or remote database

View File

@ -22,11 +22,7 @@ static constexpr const char* port = "7687";
void throw_and_stacktace(std::string message) {
Stacktrace stacktrace;
for (int i = 0; i < stacktrace.size(); i++)
message.append(fmt::format("\n at {} ({})", stacktrace[i].function,
stacktrace[i].location));
stacktrace.dump(message);
logger.info(message);
}