19 #ifndef print_function_INC
20 #define print_function_INC
36 #define T_RESET "\033[0m"
37 #define T_BLACK "\033[30m"
38 #define T_RED "\033[31m"
39 #define T_GREEN "\033[32m"
40 #define T_YELLOW "\033[33m"
41 #define T_BLUE "\033[34m"
42 #define T_MAGENTA "\033[35m"
43 #define T_CYAN "\033[36m"
44 #define T_WHITE "\033[37m"
45 #define T_BOLDBLACK "\033[1m\033[30m"
46 #define T_BOLDRED "\033[1m\033[31m"
47 #define T_BOLDGREEN "\033[1m\033[32m"
48 #define T_BOLDYELLOW "\033[1m\033[33m"
49 #define T_BOLDBLUE "\033[1m\033[34m"
50 #define T_BOLDMAGENTA "\033[1m\033[35m"
51 #define T_BOLDCYAN "\033[1m\033[36m"
52 #define T_BOLDWHITE "\033[1m\033[37m"
61 #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
63 #define MOOSE_DEBUG( a ) { \
64 stringstream ss; ss << a; \
65 cout << "DEBUG: " << __FILENAME__ << ":" << __LINE__ << "| " << ss.str(); \
68 #define MOOSE_DEBUG( a ) {}
81 "TRACE",
"DEBUG",
"INFO",
"WARNING",
"FIXME" ,
"ERROR",
"FATAL",
"FAILED"
94 template<
typename A,
typename B>
97 unsigned int width = 81;
98 unsigned int mapSize = m.size();
99 unsigned int size = 0;
105 typename map<A, B>::const_iterator it;
106 for(it = m.begin(); it != m.end(); it++)
111 ss <<
": " << it->second;
112 row.push_back(ss.str());
113 if(ss.str().size() > size)
114 size = ss.str().size()+1;
117 unsigned int colums = width / size;
121 for(
unsigned int ii = 0; ii < row.size(); ii++)
125 ss << setw(size+1) << row[ii];
144 inline string colored(
string msg,
string colorName)
147 ss << colorName << msg <<
T_RESET;
153 ,
string color=
T_RESET,
unsigned debugLevel = 0
156 stringstream ss; ss.str(
"");
159 ss << setw(debugLevel/2) <<
"[" << prefix <<
"] "
173 ss <<
"[" <<
levels_[type] <<
"] ";
179 else if(type ==
debug )
183 else if(type ==
info )
186 for(
unsigned int i = 0; i < msg.size(); ++i)
196 else if(set && !reset)
203 else if(
'\n' == msg[i])
212 cout << ss.str() << endl;
252 #define LOG(t, a ) ((void)0);
254 #define LOG(t, a) { stringstream __ss__; __ss__ << a; moose::__dump__(__ss__.str(), t ); }
269 remove_if(msg.begin(), msg.end(),
isBackTick);
282 ,
bool redirectToConsole =
true
283 ,
bool removeTicks =
true
287 if(redirectToConsole)
294 logF.open(
"__moose__.log", ios::app);
295 time_t rawtime; time(&rawtime);
297 timeinfo = localtime(&rawtime);
299 logF << asctime(timeinfo) <<
": " << msg;
serverity_level_
Enumerate type for debug and log.
void log(string msg, serverity_level_ type=debug, bool redirectToConsole=true, bool removeTicks=true)
Log to console (and to a log-file)
string debugPrint(string msg, string prefix="DEBUG", string color=T_RESET, unsigned debugLevel=0)
void showDebug(const string msg)
string mapToString(const map< A, B > &m, bool value=true)
void showError(mu::Parser::exception_type &e)
string formattedMsg(string &msg)
string colored(string msg, string colorName)
void __dump__(string msg, serverity_level_ type=debug, bool autoFormat=true)
void showInfo(string msg)
void showWarn(string msg)