Replaced Boost.Log with small custom logger

Boost.Log is a complex monstrosity and I can't get it to build on OS X.
This commit is contained in:
Daniel Wolf
2016-04-13 22:37:39 +02:00
parent 4941bff739
commit 7ce79f9c08
10 changed files with 261 additions and 164 deletions

View File

@@ -1,6 +1,7 @@
#include "tools.h"
#include <format.h>
#include <chrono>
#include <vector>
using std::string;
using std::chrono::duration;
@@ -8,3 +9,14 @@ using std::chrono::duration;
string formatDuration(duration<double> seconds) {
return fmt::format("{0:.2f}", seconds.count());
}
string formatTime(time_t time, const string& format) {
tm* timeInfo = localtime(&time);
std::vector<char> buffer(20);
bool success = false;
while (!success) {
success = strftime(buffer.data(), buffer.size(), format.c_str(), timeInfo) != 0;
if (!success) buffer.resize(buffer.size() * 2);
}
return string(buffer.data());
}