Пример #1
0
LogMessage::LogMessage( boost::log::basic_record<char> const& rRecord )
{
    // Format log message
    StringStream ss;
    msLogFormatter( ss, rRecord );
    mMessage = ss.str();

    // Get attributes
    boost::log::extract<String>( "Channel", rRecord.attribute_values(), 
        boost::lambda::var( mChannel ) = boost::lambda::_1 );
    boost::log::extract<LogLevel>( "Severity", rRecord.attribute_values(), 
        boost::lambda::var( mLogLevel ) = boost::lambda::_1 );
}
Пример #2
0
void my_formatter(bool print_all_characters, std::wostream& strm, boost::log::basic_record<wchar_t> const& rec)
{
    namespace lambda = boost::lambda;
	
	#pragma warning(disable : 4996)
	time_t rawtime;
	struct tm* timeinfo;
	time(&rawtime );
	timeinfo = localtime ( &rawtime );
	char buffer [80];
	strftime (buffer,80, "%c", timeinfo);
	strm << L"[" << buffer << L"] ";
		
    boost::log::attributes::current_thread_id::held_type thread_id;
    if(boost::log::extract<boost::log::attributes::current_thread_id::held_type>(L"ThreadID", rec.attribute_values(), lambda::var(thread_id) = lambda::_1))
        strm << L"[" << thread_id << L"] ";
	
    severity_level severity;
    if(boost::log::extract<severity_level>(boost::log::sources::aux::severity_attribute_name<wchar_t>::get(), rec.attribute_values(), lambda::var(severity) = lambda::_1))
	{
		std::stringstream ss;
		ss << severity;
        strm << L"[" << severity << L"] ";
		for(int n = 0; n < 7-static_cast<int>(ss.str().size()); ++n)
			strm << L" ";
	}

	if (print_all_characters)
	{
		strm << rec.message();
	}
	else
	{
	    strm << replace_nonprintable_copy(rec.message(), L'?');
	}
}
Пример #3
0
void my_formatter(std::wostream& strm, boost::log::basic_record<wchar_t> const& rec)
{
    namespace lambda = boost::lambda;
	
	#pragma warning(disable : 4996)
	time_t rawtime;
	struct tm* timeinfo;
	time(&rawtime );
	timeinfo = localtime ( &rawtime );
	char buffer [80];
	strftime (buffer,80, "%c", timeinfo);
	strm << L"[" << buffer << L"] ";
		
    boost::log::attributes::current_thread_id::held_type thread_id;
    if(boost::log::extract<boost::log::attributes::current_thread_id::held_type>(L"ThreadID", rec.attribute_values(), lambda::var(thread_id) = lambda::_1))
        strm << L"[" << thread_id << L"] ";

    severity_level severity;
    if(boost::log::extract<severity_level>(boost::log::sources::aux::severity_attribute_name<wchar_t>::get(), rec.attribute_values(), lambda::var(severity) = lambda::_1))
        strm << L"[" << severity << L"] ";

    strm << rec.message();
}