Get rid of current_time()

This commit is contained in:
blankie 2023-01-16 10:59:46 +07:00
parent 4411f88904
commit 79e816e105
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 2 additions and 21 deletions

23
log.cpp
View File

@ -9,25 +9,6 @@
#include "log.h"
static time_t current_time() {
static bool no_time_warned = false;
struct timespec tp;
if (!clock_gettime(CLOCK_REALTIME, &tp)) {
return tp.tv_sec;
}
if (no_time_warned) {
return 0;
}
no_time_warned = true;
std::system_error e = std::system_error(errno, std::generic_category(), "clock_gettime()");
log("Failed to get current time", std::move(e));
return 0;
}
std::string log_entries;
void log(std::string entry, time_t time) {
@ -49,7 +30,7 @@ void log(std::string entry, time_t time) {
}
void log(std::string entry) {
log(std::move(entry), current_time());
log(std::move(entry), time(nullptr));
}
void log(std::string action, const std::exception& e, time_t time) {
@ -57,7 +38,7 @@ void log(std::string action, const std::exception& e, time_t time) {
}
void log(std::string action, const std::exception& e) {
log(std::move(action), e, current_time());
log(std::move(action), e, time(nullptr));
}
std::string quote(const std::string& str) {