コード例 #1
0
// This may throw for invalid domain or level.
std::ostream& debug_out(debug_level::flag level, const std::string& domain)
{
	debug_internal::DebugState::domain_map_t& dm = debug_internal::get_debug_state().get_domain_map();

	debug_internal::DebugState::domain_map_t::iterator level_map = dm.find(domain);
	if (level_map == dm.end()) {  // no such domain
		std::string msg = "debug_out(): Debug state doesn't contain the requested domain: \"" + domain + "\".";

		if (domain != "default") {
			debug_out(debug_level::warn, "default") << msg << "\n";
			debug_out(debug_level::info, "default") << "Auto-creating the missing domain.\n";
			debug_register_domain(domain);
			debug_out(debug_level::warn, "default") << "The message follows:\n";
			return debug_out(level, domain);  // try again
		}

		// this is an internal error
		THROW_FATAL(debug_internal_error(msg.c_str()));
	}

	debug_internal::DebugState::level_map_t::iterator os = level_map->second.find(level);
	if (level_map == dm.end()) {
		std::string msg = std::string("debug_out(): Debug state doesn't contain the requested level ") +
				debug_level::get_name(level) + " in domain: \"" + domain + "\".";

		// this is an internal error
		THROW_FATAL(debug_internal_error(msg.c_str()));
	}

	return *(os->second);
}
コード例 #2
0
ファイル: functionor.c プロジェクト: weimingtom/yaavg
struct functionor_t *
find_functionor(struct function_class_t * fclass, const char * param)
{
	assert(fclass != NULL);
	struct functionor_t ** pos = *(fclass->functionors);
	if (fclass->current_functionor != NULL) {
		if (fclass->fclass & UNIQUE_FUNCTIONOR) {
			WARNING(SYSTEM, "calling find_functionor with an already inited class %d, param=\"%s\"\n",
					fclass->fclass, param);
			return fclass->current_functionor;
		}
	}
	while (*pos != NULL) {
		assert((*pos)->fclass == fclass->fclass);
		if ((*pos)->check_usable != NULL)
			if ((*pos)->check_usable(param)) {
				fclass->current_functionor = *pos;
				return *pos;
			}
		pos ++;
	}
	THROW_FATAL(EXP_FUNCTIONOR_NOT_FOUND,
			"unable to find suitable functionor for class \"%s\" "
			" with param \"%s\"",
			function_class_names[SEQ_PART(fclass->fclass)], param);
	return NULL;
}