Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BoostLogger::BoostLogger()
- {
- boost::shared_ptr< logging::core > core = logging::core::get();
- core->set_exception_handler(
- logging::make_exception_handler<std::runtime_error, std::exception>(BoostExceptionHandler{}));
- boost::shared_ptr< backendSink> backend = NULL;
- try {
- backend =
- boost::make_shared< backendSink >((
- #ifdef _M_IX86
- keywords::message_file = "c:\\automation\\IISModules\\ModuleCode86.dll",
- #else
- keywords::message_file = "c:\\automation\\IISModules\\ModuleCode64.dll",
- #endif
- keywords::log_name = "Application",
- keywords::log_source = "IIS Module Source"
- ));
- }
- catch (std::exception& e) {
- //swallow the error
- }
- sinks::event_log::event_composer composer(
- sinks::event_log::direct_event_id_mapping< int >("EventID"));
- composer[EVENTLOG_MSG]
- % expr::attr< std::string >("ProcessID")
- % expr::attr< std::string >("ThreadID")
- % expr::attr<std::string>("Message");
- backend->set_event_composer(composer);
- sinks::event_log::custom_event_type_mapping< severity_level > type_mapping("Severity");
- type_mapping[debug] = sinks::event_log::make_event_type(LOG_SEVERITY_DEBUG);
- type_mapping[info] = sinks::event_log::make_event_type(LOG_SEVERITY_INFO);
- type_mapping[warning] = sinks::event_log::make_event_type(LOG_SEVERITY_WARNING);
- type_mapping[error] = sinks::event_log::make_event_type(LOG_SEVERITY_WARNING);
- backend->set_event_type_mapper(type_mapping);
- sinks::event_log::custom_event_category_mapping< int > cat_mapping("EventID");
- cat_mapping[EVENTLOG_MSG] = sinks::event_log::make_event_category(WINMODULE_LOGGER);
- backend->set_event_category_mapper(cat_mapping);
- boost::shared_ptr<sinkImpl> sink(new sinkImpl(backend));
- sink->set_filter(expr::has_attr< int >("EventID"));
- core->add_sink(sink);
- logging::add_common_attributes();
- this->logger= loggerImpl();
- }
- void BoostLogger::LogMessage(string message)
- {
- string processId = "DEADBEEF";
- string threadId = "FEEDC0DE";
- //int
- BOOST_LOG_SCOPED_THREAD_TAG("EventID", (int)EVENTLOG_MSG);
- BOOST_LOG_SCOPED_THREAD_TAG("ProcessID", processId);
- BOOST_LOG_SCOPED_THREAD_TAG("ThreadID", threadId);
- BOOST_LOG_SCOPED_THREAD_TAG("Message", message);
- BOOST_LOG_SEV(this->logger, info)<< message ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement