Working on linux now, better logging

This commit is contained in:
2026-03-26 16:38:29 +01:00
parent 5e5e89284b
commit dd96fe1f34
14 changed files with 118 additions and 11 deletions

View File

@@ -1,7 +1,17 @@
#include "utils.h"
#include <chrono>
typedef struct {
std::chrono::time_point<std::chrono::system_clock> start;
} timer;
static int _log_level = LOG_INFO;
static timer *_timer = nullptr;
int logLevel()
{
@@ -23,3 +33,19 @@ const char *logIndicator(int l)
}
return "UNKNOWN";
}
void logElapsed()
{
if (_timer == nullptr) {
_timer = new timer;
_timer->start = std::chrono::system_clock::now();
}
auto c = std::chrono::system_clock::now();
auto duration = c - _timer->start;
auto milliseconds
= std::chrono::duration_cast<std::chrono::milliseconds>(
duration)
.count();
fprintf(stderr, "%8.3lf: ", milliseconds/ 1000.0);
}