Example #1
0
/**
 * Callback to send a message through to the core
 *
 * @param msgType Message type (debug, warning, etc.)
 * @param file File where message was generated (__FILE__)
 * @param line Line where message was generated (__LINE__)
 * @param message Message in human readable format
 * @throws nscapi::nscapi_exception When core pointer set is unavailable.
 */
void nscapi::core_wrapper::log(NSCAPI::nagiosReturn msgType, std::string file, int line, std::wstring logMessage) {
	if (!should_log(msgType))
		return;
	if (!fNSAPISimpleMessage) {
		std::wcout << _T("NSCORE NOT LOADED Dumping log: ") << line << _T(": ") << std::endl << logMessage << std::endl;
		return;
	}
	std::string str;
	try {
		/*
		Plugin::LogEntry message;
		Plugin::LogEntry::Entry *msg = message.add_entry();
		msg->set_level(nscapi::functions::log_to_gpb(msgType));
		msg->set_file(file);
		msg->set_line(line);
		msg->set_message(utf8::cvt<std::string>(logMessage));
		if (!message.SerializeToString(&str)) {
			std::wcout << _T("Failed to generate message: SERIALIZATION ERROR");
		}
		*/
		return fNSAPISimpleMessage(msgType, file.c_str(), line, logMessage.c_str());
	} catch (const std::exception &e) {
		std::wcout << _T("Failed to generate message: ") << utf8::to_unicode(e.what());
	} catch (...) {
		std::wcout << _T("Failed to generate message: UNKNOWN");
	}
}
/**
* Callback to send a message through to the core
*
* @param msgType Message type (debug, warning, etc.)
* @param file File where message was generated (__FILE__)
* @param line Line where message was generated (__LINE__)
* @param message Message in human readable format
* @throws nscapi::nscapi_exception When core pointer set is unavailable.
*/
void nscapi::core_wrapper::log(NSCAPI::nagiosReturn msgType, std::string file, int line, std::string logMessage) const {
	if (!should_log(msgType))
		return;
	if (!fNSAPISimpleMessage) {
		return;
	}
	try {
		return fNSAPISimpleMessage(alias.c_str(), msgType, file.c_str(), line, logMessage.c_str());
	} catch (...) {
	}
}
Example #3
0
/**
* Callback to send a message through to the core
*
* @param msgType Message type (debug, warning, etc.)
* @param file File where message was generated (__FILE__)
* @param line Line where message was generated (__LINE__)
* @param message Message in human readable format
* @throws nsclient::nsclient_exception When core pointer set is unavailable.
*/
void nscapi::core_wrapper::log(NSCAPI::log_level::level loglevel, std::string file, int line, std::string logMessage) const {
	if (!should_log(loglevel))
		return;
	if (!fNSAPISimpleMessage) {
		return;
	}
	try {
		return fNSAPISimpleMessage(pimpl->alias.c_str(), loglevel, file.c_str(), line, logMessage.c_str());
	} catch (...) {
	}
}