Skip to content

Commit

Permalink
Prepend current time (hires) to messages logged via ZmqLogger
Browse files Browse the repository at this point in the history
  • Loading branch information
N3WWN committed Apr 16, 2018
1 parent 54d6cf5 commit 16b9cd9
Showing 1 changed file with 9 additions and 1 deletion.
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 << "." << 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());
}
}
}

0 comments on commit 16b9cd9

Please sign in to comment.