From 77394046460813cc828abea786cc88191c0b3ee2 Mon Sep 17 00:00:00 2001 From: jackb-p Date: Fri, 12 Aug 2016 15:30:47 +0100 Subject: [PATCH] Compatability for g++ 4.9 --- TriviaBot/bot/Logger.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/TriviaBot/bot/Logger.cpp b/TriviaBot/bot/Logger.cpp index 6d2a626..ea09cd6 100644 --- a/TriviaBot/bot/Logger.cpp +++ b/TriviaBot/bot/Logger.cpp @@ -1,7 +1,6 @@ #include "Logger.hpp" #include -#include #include namespace Logger { @@ -33,9 +32,16 @@ namespace Logger { } void write(std::string text, LogLevel log_level) { - auto t = std::time(nullptr); - auto tm = *std::localtime(&t); + time_t rawtime; + struct tm *timeinfo; + char buffer[80]; - get_ostream(log_level) << "[" << std::put_time(&tm, "%Y-%m-%d %H:%M:%S") << "] [" << log_level << "] " << text << std::endl; + time(&rawtime); + timeinfo = localtime(&rawtime); + + strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", timeinfo); + std::string time_str(buffer); + + get_ostream(log_level) << "[" << time_str << "] [" << log_level << "] " << text << std::endl; } -} \ No newline at end of file +}