void realDebugmsg( const char *filename, const char *line, const char *funcname, const char *mes, ... ) { assert( filename != nullptr ); assert( line != nullptr ); assert( funcname != nullptr ); va_list ap; va_start( ap, mes ); const std::string text = vstring_format( mes, ap ); va_end( ap ); if( debug_fatal ) { throw std::runtime_error( string_format( "%s:%s [%s] %s", filename, line, funcname, text.c_str() ) ); } DebugLog( D_ERROR, D_MAIN ) << filename << ":" << line << " [" << funcname << "] " << text; std::string msg_key( filename ); msg_key += line; if( ignored_messages.count( msg_key ) > 0 ) { return; } if( stdscr == nullptr ) { std::cerr << text.c_str() << std::endl; abort(); } fold_and_print( stdscr, 0, 0, getmaxx( stdscr ), c_ltred, "\n \n" // Looks nicer with some space " DEBUG : %s\n \n" " FUNCTION : %s\n" " FILE : %s\n" " LINE : %s\n \n" " Press <color_white>spacebar</color> to continue the game...\n" " Press <color_white>I</color> (or <color_white>i</color>) to also ignore this particular message in the future...", text.c_str(), funcname, filename, line ); for( bool stop = false; !stop; ) { switch( getch() ) { case 'i': case 'I': ignored_messages.insert( msg_key ); // Falling through case ' ': stop = true; break; } } werase( stdscr ); refresh(); }
void realDebugmsg( const char *filename, const char *line, const char *funcname, const std::string &text ) { assert( filename != nullptr ); assert( line != nullptr ); assert( funcname != nullptr ); if( test_mode ) { test_dirty = true; std::cerr << filename << ":" << line << " [" << funcname << "] " << text << std::endl; return; } DebugLog( D_ERROR, D_MAIN ) << filename << ":" << line << " [" << funcname << "] " << text; std::string msg_key( filename ); msg_key += line; if( ignored_messages.count( msg_key ) > 0 ) { return; } if( stdscr == nullptr ) { std::cerr << text << std::endl; abort(); } fold_and_print( stdscr, 0, 0, getmaxx( stdscr ), c_light_red, "\n \n" // Looks nicer with some space " DEBUG : %s\n \n" " FUNCTION : %s\n" " FILE : %s\n" " LINE : %s\n \n" " Press <color_white>spacebar</color> to continue the game...\n" " Press <color_white>I</color> (or <color_white>i</color>) to also ignore this particular message in the future...", text.c_str(), funcname, filename, line ); for( bool stop = false; !stop; ) { switch( inp_mngr.get_input_event().get_first_input() ) { case 'i': case 'I': ignored_messages.insert( msg_key ); /* fallthrough */ case ' ': stop = true; break; } } werase( stdscr ); refresh(); }