Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepend current time (hires) to messages logged via ZmqLogger #82

Merged
merged 2 commits into from
Apr 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/ZmqLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ void ZmqLogger::AppendDebugMethod(string method_name, string arg1_name, float ar

stringstream message;
message << fixed << setprecision(4);

// Prepend current time (hires) to message
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
char timebuf[80];
strftime(timebuf, sizeof timebuf, "%F %T", localtime(&ts.tv_sec));
message << timebuf << "." << std::setiosflags(std::ios::right) << std::setw(9) << std::setfill('0') << ts.tv_nsec << " ";

message << method_name << " (";

// Add attributes to method JSON
Expand Down Expand Up @@ -203,4 +211,4 @@ void ZmqLogger::AppendDebugMethod(string method_name, string arg1_name, float ar
// Send message through ZMQ
Log(message.str());
}
}
}