const char* CondorError::getFullText( bool want_newline ) { PRAGMA_REMIND("Why keep this static? -matt"); static std::string errbuf; bool printed_one = false; errbuf = ""; CondorError* walk = _next; while (walk) { if( printed_one ) { if( want_newline ) { errbuf += '\n'; } else { errbuf += '|'; } } else { printed_one = true; } errbuf += walk->_subsys; errbuf += ':'; errbuf += walk->_code; errbuf += ':'; errbuf += walk->_message; walk = walk->_next; } return errbuf.c_str(); }
void initTypes( int max_types, StringList **type_strings, int except ) { int i; char* tmp; MyString buf; _checkInvalidParam("SLOT_TYPE_0", except); // CRUFT _checkInvalidParam("VIRTUAL_MACHINE_TYPE_0", except); if (! type_strings[0]) { // Type 0 is the special type for evenly divided slots. type_strings[0] = new StringList(); type_strings[0]->initializeFromString("auto"); } for( i=1; i < max_types; i++ ) { if( type_strings[i] ) { continue; } buf.formatstr("SLOT_TYPE_%d", i); tmp = param(buf.Value()); if (!tmp) { if (param_boolean("ALLOW_VM_CRUFT", false)) { buf.formatstr("VIRTUAL_MACHINE_TYPE_%d", i); if (!(tmp = param(buf.Value()))) { continue; } } else { continue; } } type_strings[i] = new StringList(); type_strings[i]->initializeFromString( tmp ); free( tmp ); #if 0 // check for pairings buf += "PAIRED_WITH"; tmp = param(buf.Value()); if ( ! tmp) continue; PRAGMA_REMIND("tj: treating the slot that has PAIRED_WITH as subordinate! fix this!") type_strings[i]->insert("minimal"); free (tmp); #endif } }
void dprintf_set_outputs(const struct dprintf_output_settings *p_info, int c_info) { static int first_time = 1; std::vector<DebugFileInfo> *debugLogsOld = DebugLogs; DebugLogs = new std::vector<DebugFileInfo>(); /* ** We want to initialize this here so if we reconfig and the ** debug flags have changed, we actually use the new ** flags. -Derek Wright 12/8/97 */ AnyDebugBasicListener = 1<<D_ALWAYS | 1<<D_ERROR | 1<<D_STATUS; AnyDebugVerboseListener = 0; DebugHeaderOptions = 0; /* ** If this is not going to the terminal, pick up the name ** of the log file, maximum log size, and the name of the ** lock file (if it is specified). */ std::vector<DebugFileInfo>::iterator it; //iterator indicating the file we got to. for (int ii = 0; ii < c_info; ++ii) { std::string logPath = p_info[ii].logPath; if(!logPath.empty()) { // merge flags if we see the same log file name more than once. // we don't really expect this to happen, but things get weird of // it does happen and we don't check for it. // for(it = DebugLogs->begin(); it != DebugLogs->end(); ++it) { if(it->logPath != logPath) continue; it->choice |= p_info[ii].choice; break; } if(it == DebugLogs->end()) // We did not find the logPath in our DebugLogs { it = DebugLogs->insert(DebugLogs->end(),p_info[ii]); if(logPath == "1>") { it->outputTarget = STD_OUT; it->debugFP = stdout; it->dprintfFunc = _dprintf_global_func; } else if(logPath == "2>") { it->outputTarget = STD_ERR; it->debugFP = stderr; it->dprintfFunc = _dprintf_global_func; } #ifdef WIN32 else if(logPath == "OUTDBGSTR") { it->outputTarget = OUTPUT_DEBUG_STR; it->dprintfFunc = dprintf_to_outdbgstr; } #else else if (logPath == "SYSLOG") { // Intention is to eventually user-selected it->dprintfFunc = DprintfSyslog::Log; it->outputTarget = SYSLOG; it->userData = static_cast<void*>(DprintfSyslogFactory::NewLog(LOG_DAEMON)); } #endif else { it->outputTarget = FILE_OUT; it->dprintfFunc = _dprintf_global_func; } /* This seems like a catch all default that we did not want. else { it->outputTarget = ((ii == 0) && Termlog) ? STD_OUT : FILE_OUT; it->dprintfFunc = _dprintf_global_func; } */ it->logPath = logPath; } if (ii == 0) { if(first_time && it->outputTarget == FILE_OUT) { struct stat stat_buf; if ( stat( logPath.c_str(), &stat_buf ) >= 0 ) { DebugLastMod = stat_buf.st_mtime > stat_buf.st_ctime ? stat_buf.st_mtime : stat_buf.st_ctime; } else { DebugLastMod = -errno; } } PRAGMA_REMIND("TJ: fix this when choice includes verbose.") AnyDebugBasicListener = p_info[ii].choice; AnyDebugVerboseListener = p_info[ii].VerboseCats; DebugHeaderOptions = p_info[ii].HeaderOpts; } else { AnyDebugBasicListener |= p_info[ii].choice; AnyDebugVerboseListener |= p_info[ii].VerboseCats; } // check to see if we can open the log file. if(it->outputTarget == FILE_OUT) { bool dont_panic = true; bool fOk = debug_check_it(*it, (first_time && it->want_truncate), dont_panic); if( ! fOk && ii == 0 ) { #ifdef WIN32 /* ** If we could not open the log file, we might want to keep running anyway. ** If we do, then set the log filename to NUL so we don't keep trying ** (and failing) to open the file. */ if (DebugContinueOnOpenFailure) { // change the debug file to point to the NUL device. it->logPath.insert(0, NULL_FILE); } else #endif { EXCEPT("Cannot open log file '%s'", logPath.c_str()); } } } } } if ( ! p_info || ! c_info || p_info[0].logPath == "2>" || p_info[0].logPath == "CON:" || p_info[0].logPath == "\\dev\\tty") { #if !defined(WIN32) setlinebuf( stderr ); #endif (void)fflush( stderr ); /* Don't know why we need this, but if not here the first couple dprintf don't come out right */ } first_time = 0; _condor_dprintf_works = 1; #if HAVE_BACKTRACE install_backtrace_handler(); #endif if(debugLogsOld) { for (it = debugLogsOld->begin(); it != debugLogsOld->end(); it++) { if ((it->outputTarget == SYSLOG) && (it->userData)) { #if !defined(WIN32) delete static_cast<DprintfSyslog*>(it->userData); #endif } } delete debugLogsOld; } _condor_dprintf_saved_lines(); }