2011-07-13 23:12:36 +02:00
|
|
|
#include "logger.h"
|
2011-04-06 21:46:58 +02:00
|
|
|
|
|
|
|
#include <iostream>
|
2011-04-07 10:45:58 +02:00
|
|
|
#include <cstdlib>
|
2010-11-18 23:13:35 +01:00
|
|
|
|
2011-07-17 02:13:53 +02:00
|
|
|
void log(LogLevel level, const std::string& message, std::string prettyFunction)
|
2010-11-18 23:13:35 +01:00
|
|
|
{
|
2011-07-17 02:13:53 +02:00
|
|
|
if(!prettyFunction.empty()) {
|
|
|
|
prettyFunction = prettyFunction.substr(0, prettyFunction.find_first_of('('));
|
|
|
|
if(prettyFunction.find_last_of(' ') != std::string::npos)
|
|
|
|
prettyFunction = prettyFunction.substr(prettyFunction.find_last_of(' ') + 1);
|
|
|
|
if(!prettyFunction.empty())
|
|
|
|
std::cout << "[" << prettyFunction << "] ";
|
2010-11-18 23:13:35 +01:00
|
|
|
}
|
|
|
|
|
2011-07-17 02:13:53 +02:00
|
|
|
std::cout << message << std::endl;
|
2010-11-18 23:13:35 +01:00
|
|
|
|
2011-07-13 23:12:36 +02:00
|
|
|
if(level == LogFatal)
|
2010-11-18 23:13:35 +01:00
|
|
|
exit(-1);
|
|
|
|
}
|