void DTMReader::readDatatype(std::string descriptor) throw(DTMReadException) { DOMXMLParser parser; if ( parser.parse( ((char*)descriptor.c_str()) ) != 0 ) { std::cerr << "Error during XML parsing" << std::endl; throw DTMReadException(); } dtm_document_ = parser.getDocument(); DOMNode* child = dtm_document_->getDocumentElement()->getFirstChild(); while (child != 0) { if (child->getNodeType() == DOMNode::ELEMENT_NODE) // handle type_mapping if ( !XMLString::compareString(child->getNodeName(), X("type-mapping")) ) type_mapping((DOMElement*)child); // get next child child = child->getNextSibling(); } }
void init_logging() { //[ example_sinks_event_log_create_backend // Create an event log sink boost::shared_ptr< sinks::event_log_backend > backend( new sinks::event_log_backend(( keywords::message_file = "%SystemDir%\\event_log_messages.dll", keywords::log_name = "My Application", keywords::log_source = "My Source" )) ); //] //[ example_sinks_event_log_event_composer // Create an event composer. It is initialized with the event identifier mapping. sinks::event_log::event_composer composer( sinks::event_log::direct_event_id_mapping< int >("EventID")); // For each event described in the message file, set up the insertion string formatters composer[LOW_DISK_SPACE_MSG] // the first placeholder in the message // will be replaced with contents of the "Drive" attribute % fmt::attr< std::string >("Drive") // the second placeholder in the message // will be replaced with contents of the "Size" attribute % fmt::attr< boost::uintmax_t >("Size"); composer[DEVICE_INACCESSIBLE_MSG] % fmt::attr< std::string >("Drive"); composer[SUCCEEDED_MSG] % fmt::attr< unsigned int >("Duration"); // Then put the composer to the backend backend->set_event_composer(composer); //] //[ example_sinks_event_log_mappings // We'll have to map our custom levels to the event log event types sinks::event_log::custom_event_type_mapping< severity_level > type_mapping("Severity"); type_mapping[normal] = sinks::event_log::make_event_type(MY_SEVERITY_INFO); type_mapping[warning] = sinks::event_log::make_event_type(MY_SEVERITY_WARNING); type_mapping[error] = sinks::event_log::make_event_type(MY_SEVERITY_ERROR); backend->set_event_type_mapper(type_mapping); // Same for event categories. // Usually event categories can be restored by the event identifier. sinks::event_log::custom_event_category_mapping< int > cat_mapping("EventID"); cat_mapping[LOW_DISK_SPACE_MSG] = sinks::event_log::make_event_category(MY_CATEGORY_1); cat_mapping[DEVICE_INACCESSIBLE_MSG] = sinks::event_log::make_event_category(MY_CATEGORY_2); cat_mapping[SUCCEEDED_MSG] = sinks::event_log::make_event_category(MY_CATEGORY_3); backend->set_event_category_mapper(cat_mapping); //] //[ example_sinks_event_log_register_sink // Create the frontend for the sink boost::shared_ptr< sinks::synchronous_sink< sinks::event_log_backend > > sink( new sinks::synchronous_sink< sinks::event_log_backend >(backend)); // Set up filter to pass only records that have the necessary attribute sink->set_filter(flt::has_attr< int >("EventID")); logging::core::get()->add_sink(sink); //] }