1 /* 2 * Copyright Andrey Semashev 2007 - 2015. 3 * Distributed under the Boost Software License, Version 1.0. 4 * (See accompanying file LICENSE_1_0.txt or copy at 5 * http://www.boost.org/LICENSE_1_0.txt) 6 */ 7 /*! 8 * \file default_sink.hpp 9 * \author Andrey Semashev 10 * \date 08.01.2012 11 * 12 * \brief This header is the Boost.Log library implementation, see the library documentation 13 * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html. 14 */ 15 16 #ifndef BOOST_LOG_DEFAULT_SINK_HPP_INCLUDED_ 17 #define BOOST_LOG_DEFAULT_SINK_HPP_INCLUDED_ 18 19 #include <boost/log/detail/config.hpp> 20 #include <boost/log/sinks/sink.hpp> 21 #include <boost/log/attributes/attribute_name.hpp> 22 #include <boost/log/attributes/value_extraction.hpp> 23 #include <boost/log/attributes/value_visitation.hpp> 24 #include <boost/log/attributes/fallback_policy.hpp> 25 #include <boost/log/expressions/message.hpp> 26 #include <boost/log/trivial.hpp> 27 #if !defined(BOOST_LOG_NO_THREADS) 28 #include <boost/thread/mutex.hpp> 29 #endif 30 #include <boost/log/detail/header.hpp> 31 32 #ifdef BOOST_HAS_PRAGMA_ONCE 33 #pragma once 34 #endif 35 36 namespace boost { 37 38 BOOST_LOG_OPEN_NAMESPACE 39 40 namespace sinks { 41 42 namespace aux { 43 44 //! The default sink to be used when no sinks are registered in the logging core 45 class default_sink : 46 public sink 47 { 48 private: 49 #if !defined(BOOST_LOG_NO_THREADS) 50 typedef mutex mutex_type; 51 mutex_type m_mutex; 52 #endif 53 attribute_name const m_severity_name, m_message_name; 54 value_extractor< boost::log::trivial::severity_level, fallback_to_default< boost::log::trivial::severity_level > > const m_severity_extractor; 55 value_visitor_invoker< expressions::tag::message::value_type > m_message_visitor; 56 57 public: 58 default_sink(); 59 ~default_sink() BOOST_OVERRIDE; 60 bool will_consume(attribute_value_set const&) BOOST_OVERRIDE; 61 void consume(record_view const& rec) BOOST_OVERRIDE; 62 void flush() BOOST_OVERRIDE; 63 }; 64 65 } // namespace aux 66 67 } // namespace sinks 68 69 BOOST_LOG_CLOSE_NAMESPACE // namespace log 70 71 } // namespace boost 72 73 #include <boost/log/detail/footer.hpp> 74 75 #endif // BOOST_LOG_DEFAULT_SINK_HPP_INCLUDED_ 76