Skip to content

Commit

Permalink
Add time since epoch in logging statements (#21)
Browse files Browse the repository at this point in the history
* Log time since epoch

* cleanup

* Simplify

* Lint
  • Loading branch information
lukeschmitt-tr authored Aug 12, 2024
1 parent f2932de commit a7dd912
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/xs_logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@
#include <stdio.h>
#include <stdlib.h>

#include <memory>
#include <chrono>
#include <cstdarg>
#include <cstdio>
#include <iostream>
#include <memory>
#include <sstream>
#include <string>
#include <vector>
#include <iostream>


namespace interbotix_xs
Expand Down Expand Up @@ -81,6 +82,14 @@ void log(logging::Level level, const char * fmt, ...)
break;
}

auto duration = std::chrono::system_clock::now().time_since_epoch();
double seconds = std::chrono::duration<double>(duration).count();

msg = msg +
" [" +
std::to_string(seconds) +
"] ";

va_list args;
va_start(args, fmt);
size_t size = 1024;
Expand Down

0 comments on commit a7dd912

Please sign in to comment.