diff options
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp index 53f90eb..de2c9d8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,15 +1,24 @@ #include "core/Core.hpp" -#define ELPP_THREAD_SAFE -#define ELPP_FEATURE_CRASH_LOG -#define ELPP_DISABLE_LOGS +const char *getTimeSinceProgramStart(void) { + static auto initialTime = std::chrono::steady_clock().now(); + auto now = std::chrono::steady_clock().now(); + std::chrono::duration<double> seconds = now-initialTime; + static char buffer[30]; + sprintf(buffer, "%.2f", seconds.count()); + return buffer; +} + INITIALIZE_EASYLOGGINGPP int main() { el::Configurations loggerConfiguration; - std::string format = "[%level]{%fbase}: %msg"; + el::Helpers::installCustomFormatSpecifier( + el::CustomFormatSpecifier("%startTime", std::bind(getTimeSinceProgramStart))); + std::string format = "[%startTime][%level][%fbase]: %msg"; loggerConfiguration.set(el::Level::Info, el::ConfigurationType::Format, format); loggerConfiguration.set(el::Level::Error, el::ConfigurationType::Format, format); + loggerConfiguration.set(el::Level::Fatal, el::ConfigurationType::Format, format); el::Loggers::reconfigureAllLoggers(loggerConfiguration); el::Loggers::addFlag(el::LoggingFlag::ColoredTerminalOutput); LOG(INFO) << "Logger is configured"; |