Get rid of current_time()
This commit is contained in:
parent
4411f88904
commit
79e816e105
23
log.cpp
23
log.cpp
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue