| 7 | #include <algorithm> |
| 8 | |
| 9 | void LoggingService::log(Priority priority, std::string const& message) |
| 10 | { |
| 11 | std::lock_guard<std::mutex> lock(_mutex); |
| 12 | |
| 13 | auto t = std::time(nullptr); |
| 14 | auto tm = *std::localtime(&t); |
| 15 | |
| 16 | std::stringstream stream; |
| 17 | stream << std::put_time(&tm, "%Y-%m-%d %H-%M-%S") << ": " << message; |
| 18 | |
| 19 | auto enrichedMessage = stream.str(); |
| 20 | for (auto const& callback : _callbacks) { |
| 21 | callback->newLogMessage(priority, enrichedMessage); |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | void LoggingService::registerCallBack(LoggingCallBack* callback) |
| 26 | { |