31 std::string
retokenize(
const char* format,
const char* prefix)
34 bool carriage_return =
false;
35 const char* start_p = format;
37 for (
const char* p = format; *p ==
'\r' || *p ==
' '; ++p)
41 carriage_return =
true;
47 std::string new_format;
48 if (carriage_return ==
false)
49 new_format = std::string( prefix );
51 for (
const char* p = start_p; *p !=
'\0'; ++p)
55 new_format.append( 1u,
'\n' );
61 new_format.append( 1u,
'\r' );
66 new_format.append( 1u,*p );
76 unsigned int TEXT_RED = FOREGROUND_RED;
91 HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
92 SetConsoleTextAttribute(hConsole,color);
101 const std::string new_format =
retokenize( format,
"visible : " );
104 va_start(args, format);
105 vfprintf(stream, new_format.c_str(), args);
110 void log_info(FILE* stream,
const char* format, ...)
116 const std::string new_format =
retokenize( format,
"info : " );
119 va_start(args, format);
120 vfprintf(stream, new_format.c_str(), args);
125 void log_stats(FILE* stream,
const char* format, ...)
129 const std::string new_format =
retokenize( format,
"stats : " );
132 va_start(args, format);
133 vfprintf(stream, new_format.c_str(), args);
138 void log_verbose(FILE* stream,
const char* format, ...)
144 const std::string new_format =
retokenize( format,
"verbose : " );
147 va_start(args, format);
148 vfprintf(stream, new_format.c_str(), args);
153 void log_debug(FILE* stream,
const char* format, ...)
159 const std::string new_format =
retokenize( format,
"debug : " );
162 va_start(args, format);
163 vfprintf(stream, new_format.c_str(), args);
168 void log_warning(FILE* stream,
const char* format, ...)
174 const std::string new_format =
retokenize( format,
"warning : " );
177 va_start(args, format);
178 vfprintf(stream, new_format.c_str(), args);
183 void log_error(FILE* stream,
const char* format, ...)
189 const std::string new_format =
retokenize( format,
"error : " );
192 va_start(args, format);
193 vfprintf(stream, new_format.c_str(), args);
207 va_start(args, format);
208 vfprintf(stream, format, args);
221 va_start(args, format);
222 vfprintf(stream, format, args);
233 const std::string new_format =
retokenize( format,
"stats : " );
236 va_start(args, format);
237 vfprintf(stream, new_format.c_str(), args);
250 va_start(args, format);
251 vfprintf(stream, format, args);
264 va_start(args, format);
265 vfprintf(stream, format, args);
278 va_start(args, format);
279 vfprintf(stream, format, args);
292 va_start(args, format);
293 vfprintf(stream, format, args);
323 const std::string new_format =
retokenize( format,
"visible : " );
324 char col_format[2048];
325 sprintf( col_format,
"%s%s", TEXT_BRIGHT, new_format.c_str() );
327 va_start(args, format);
328 vfprintf(stream, col_format, args);
332 void log_info(FILE* stream,
const char* format, ...)
334 if (s_verbosity >=
V_INFO)
336 const std::string new_format =
retokenize( format,
"info : " );
337 char col_format[2048];
338 sprintf( col_format,
"%s%s", TEXT_NORMAL, new_format.c_str() );
340 va_start(args, format);
341 vfprintf(stream, col_format, args);
349 const std::string new_format =
retokenize( format,
"stats : " );
350 char col_format[2048];
351 sprintf( col_format,
"%s%s", TEXT_CYAN, new_format.c_str() );
353 va_start(args, format);
354 vfprintf(stream, col_format, args);
362 const std::string new_format =
retokenize( format,
"verbose : " );
363 char col_format[2048];
364 sprintf( col_format,
"%s%s", TEXT_GREEN, new_format.c_str() );
366 va_start(args, format);
367 vfprintf(stream, col_format, args);
375 const std::string new_format =
retokenize( format,
"debug : " );
376 char col_format[2048];
377 sprintf( col_format,
"%s%s", TEXT_RED, new_format.c_str() );
379 va_start(args, format);
380 vfprintf(stream, col_format, args);
388 const std::string new_format =
retokenize( format,
"warning : " );
389 char col_format[2048];
390 sprintf( col_format,
"%s%s", TEXT_BRIGHT_MAGENTA, new_format.c_str() );
392 va_start(args, format);
393 vfprintf(stream, col_format, args);
401 const std::string new_format =
retokenize( format,
"error : " );
402 char col_format[2048];
403 sprintf( col_format,
"%s%s", TEXT_BRIGHT_RED, new_format.c_str() );
405 va_start(args, format);
406 vfprintf(stream, col_format, args);
415 char col_format[2048];
416 sprintf( col_format,
"%s%s", TEXT_BRIGHT, format );
418 va_start(args, format);
419 vfprintf(stream, col_format, args);
425 if (s_verbosity >=
V_INFO)
427 char col_format[2048];
428 sprintf( col_format,
"%s%s", TEXT_NORMAL, format );
430 va_start(args, format);
431 vfprintf(stream, col_format, args);
439 char col_format[2048];
440 sprintf( col_format,
"%s%s", TEXT_CYAN, format );
442 va_start(args, format);
443 vfprintf(stream, col_format, args);
451 char col_format[2048];
452 sprintf( col_format,
"%s%s", TEXT_GREEN, format );
454 va_start(args, format);
455 vfprintf(stream, col_format, args);
463 char col_format[2048];
464 sprintf( col_format,
"%s%s", TEXT_RED, format );
466 va_start(args, format);
467 vfprintf(stream, col_format, args);
475 char col_format[2048];
476 sprintf( col_format,
"%s%s", TEXT_BRIGHT_MAGENTA, format );
478 va_start(args, format);
479 vfprintf(stream, col_format, args);
487 char col_format[2048];
488 sprintf( col_format,
"%s%s", TEXT_BRIGHT_RED, format );
490 va_start(args, format);
491 vfprintf(stream, col_format, args);
501 fprintf(stream,
"\n");
505 if (s_verbosity >=
V_INFO)
506 fprintf(stream,
"\n");
511 fprintf(stream,
"\n");
516 fprintf(stream,
"\n");
521 fprintf(stream,
"\n");
526 fprintf(stream,
"\n");
531 fprintf(stream,
"\n");