Minor changes here and there.
[aesalon.git] / src / util / MessageSystem.cpp
blob7be987964fcbf1437dbe02d801db065d16dafae7
1 /** Aesalon, a tool to visualize program behaviour in real time.
2 Copyright (C) 2009-2011, Aesalon development team.
4 Aesalon is distributed under the terms of the GNU GPLv3. See
5 the included file LICENSE for more information.
7 @file src/util/MessageSystem.cpp
8 */
10 #include <iostream>
11 #include <cstdlib>
12 #include <ctime>
13 #include <cstdio>
15 #include "util/MessageSystem.h"
17 namespace Util {
19 void MessageSystem::writeMessage(MessageSystem::MessageLevel level, const std::string &message) {
20 std::time_t t = std::time(NULL);
22 struct tm *lt = std::localtime(&t);
24 std::string time = Util::StreamAsString() << lt->tm_hour << ":" << lt->tm_min << ":" << lt->tm_sec;
26 std::printf("[%02i:%02i:%02i %5s] ", lt->tm_hour, lt->tm_min, lt->tm_sec, LevelString(level));
27 std::puts(message.c_str());
29 if(level == Fatal) exit(1);
32 } // namespace Util