Minor Log.cpp update.

This commit is contained in:
Brad Arant 2020-04-13 09:39:01 -07:00
parent 947eef21e2
commit bf1db47043
2 changed files with 13 additions and 8 deletions

19
Log.cpp
View File

@ -18,13 +18,18 @@ namespace coreutils {
Log::Log(int level) { Log::Log(int level) {
output = true; output = true;
std::stringstream temp;
struct timespec timex;
clock_gettime(CLOCK_REALTIME, &timex);
temp << timex.tv_sec << "." << std::setfill('0') << std::setw(9) << timex.tv_nsec;
// auto clock = std::chrono::system_clock::now();
// time_t theTime = std::chrono::system_clock::to_time_t(clock);
// std::string timeOut = std::string(ctime(&theTime));
// timeOut = timeOut.substr(0, timeOut.length() - 1);
auto clock = std::chrono::system_clock::now(); *this << temp.str();
time_t theTime = std::chrono::system_clock::to_time_t(clock);
std::string timeOut = std::string(ctime(&theTime));
timeOut = timeOut.substr(0, timeOut.length() - 1);
*this << timeOut;
*this << " "; *this << " ";
switch(level) { switch(level) {
@ -63,7 +68,7 @@ namespace coreutils {
if(output) { if(output) {
std::stringstream out; std::stringstream out;
out << seq << "." << this->str() << std::endl;; out << this->str() << std::endl;;
mtx.lock(); mtx.lock();

View File

@ -33,6 +33,6 @@
#include <openssl/rand.h> #include <openssl/rand.h>
#include <openssl/err.h> #include <openssl/err.h>
#include <dirent.h> #include <dirent.h>
#include <iomanip>