35 #define COLOR_NORMAL FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED
36 #define COLOR_RED FOREGROUND_RED | FOREGROUND_INTENSITY
37 #define COLOR_GREEN FOREGROUND_GREEN
38 #define COLOR_YELLOW FOREGROUND_GREEN | FOREGROUND_RED
40 #define COLOR_NORMAL "\033[0m"
41 #define COLOR_RED "\033[31m"
42 #define COLOR_GREEN "\033[32m"
43 #define COLOR_YELLOW "\033[33m"
89 virtual void _write(
const char* msg, va_list arg)
136 std::ofstream fileToClear(
fileName_.c_str(), std::ios::out);
148 printf(
"FileLogger : Cannot open file : %s\n",
fileName_.c_str());
154 virtual void _write(
const char* msg, va_list arg)
158 vfprintf(
fout_, msg, arg);
165 fprintf(
fout_,
"%s", msg);
256 std::string endline =
"";
261 std::string time =
"";
310 const char *
function,
337 const char* color = NULL;
358 std::string endline =
"";
363 std::string time =
"";
371 std::string levelStr =
"";
374 const int bufSize = 30;
375 char buf[bufSize] = {0};
383 levelStr.append(
" ");
386 std::string whereStr =
"";
393 whereStr.append(file);
401 fileName.append(
"~");
403 whereStr.append(fileName);
407 whereStr.append(
":");
409 whereStr.append(lineStr);
412 whereStr.append(
"::");
413 std::string funcStr =
function;
419 funcStr.append(
"()");
420 whereStr.append(funcStr);
422 whereStr.append(
" ");
431 HANDLE H = GetStdHandle(STD_OUTPUT_HANDLE);
436 SetConsoleTextAttribute(H,color);
491 printf(
"\n*******\n%s message occurred! Application will now exit.\n",
levelName_[
level]);
494 printf(
" %s%s%s\n", levelStr.c_str(), time.c_str(), whereStr.c_str());
518 const int bufSize = 30;
519 char buf[bufSize] = {0};
524 localtime_s (&timeinfo, &rawtime );
525 int result = sprintf_s(buf, bufSize,
"%d-%s%d-%s%d %s%d:%s%d:%s%d",
526 timeinfo.tm_year+1900,
527 (timeinfo.tm_mon+1) < 10 ?
"0":
"", timeinfo.tm_mon+1,
528 (timeinfo.tm_mday) < 10 ?
"0":
"", timeinfo.tm_mday,
529 (timeinfo.tm_hour) < 10 ?
"0":
"", timeinfo.tm_hour,
530 (timeinfo.tm_min) < 10 ?
"0":
"", timeinfo.tm_min,
531 (timeinfo.tm_sec) < 10 ?
"0":
"", timeinfo.tm_sec);
535 timeinfo = *localtime (&rawtime);
536 int result = snprintf(buf, bufSize,
"%d-%s%d-%s%d %s%d:%s%d:%s%d",
537 timeinfo.tm_year+1900,
538 (timeinfo.tm_mon+1) < 10 ?
"0":
"", timeinfo.tm_mon+1,
539 (timeinfo.tm_mday) < 10 ?
"0":
"", timeinfo.tm_mday,
540 (timeinfo.tm_hour) < 10 ?
"0":
"", timeinfo.tm_hour,
541 (timeinfo.tm_min) < 10 ?
"0":
"", timeinfo.tm_min,
542 (timeinfo.tm_sec) < 10 ?
"0":
"", timeinfo.tm_sec);
544 struct timeval rawtime;
545 gettimeofday(&rawtime, NULL);
546 localtime_r (&rawtime.tv_sec, &timeinfo);
547 int result = snprintf(buf, bufSize,
"%d-%s%d-%s%d %s%d:%s%d:%s%d.%s%d",
548 timeinfo.tm_year+1900,
549 (timeinfo.tm_mon+1) < 10 ?
"0":
"", timeinfo.tm_mon+1,
550 (timeinfo.tm_mday) < 10 ?
"0":
"", timeinfo.tm_mday,
551 (timeinfo.tm_hour) < 10 ?
"0":
"", timeinfo.tm_hour,
552 (timeinfo.tm_min) < 10 ?
"0":
"", timeinfo.tm_min,
553 (timeinfo.tm_sec) < 10 ?
"0":
"", timeinfo.tm_sec,
554 (rawtime.tv_usec/1000) < 10 ?
"00":(rawtime.tv_usec/1000) < 100?
"0":
"",
int(rawtime.tv_usec/1000));