/* * The caller is assumed to have checked that the priority allows this * entry to be logged. */ static void con_force_puts(const con_priority priority, char *const buffer, const size_t len) { con_add_buffer_line(priority, buffer, len); con_scrub_markup(buffer); /* Produce a sanitised version and send it to the console */ con_print_file(buffer); }
void con_printf(int priority, char *fmt, ...) { va_list arglist; char buffer[CON_LINE_LENGTH]; memset(buffer,'\0',CON_LINE_LENGTH); if (priority <= ((int)GameArg.DbgVerbose)) { char *p1, *p2; va_start (arglist, fmt); vsprintf (buffer, fmt, arglist); va_end (arglist); /* Produce a sanitised version and send it to the console */ p1 = p2 = buffer; do switch (*p1) { case CC_COLOR: case CC_LSPACING: p1++; case CC_UNDERLINE: p1++; break; default: *p2++ = *p1++; } while (*p1); *p2 = 0; /* add given string to con_buffer */ con_add_buffer_line(priority, buffer); /* Print output to stdout */ printf(buffer); /* Print output to gamelog.txt */ if (gamelog_fp) { struct tm *lt; time_t t; t=time(NULL); lt=localtime(&t); PHYSFSX_printf(gamelog_fp,"%02i:%02i:%02i ",lt->tm_hour,lt->tm_min,lt->tm_sec); #ifdef _WIN32 // stupid hack to force DOS-style newlines if (buffer[strlen(buffer)-1] == '\n' && strlen(buffer) <= CON_LINE_LENGTH) { buffer[strlen(buffer)-1]='\r'; buffer[strlen(buffer)]='\n'; } #endif PHYSFSX_printf(gamelog_fp,"%s",buffer); } } }
void con_puts(const con_priority_wrapper priority, const char *const buffer, const size_t len) { if (priority <= CGameArg.DbgVerbose) { typename con_priority_wrapper::scratch_buffer<CON_LINE_LENGTH> scratch_buffer; auto &&b = priority.prepare_buffer(scratch_buffer, buffer, len); /* add given string to con_buffer */ con_add_buffer_line(priority, b.first, b.second); con_print_file(b.first); } }