|
||||
File indexing completed on 2025-01-18 09:39:25
0001 /* 0002 * Copyright Andrey Semashev 2007 - 2015. 0003 * Distributed under the Boost Software License, Version 1.0. 0004 * (See accompanying file LICENSE_1_0.txt or copy at 0005 * http://www.boost.org/LICENSE_1_0.txt) 0006 */ 0007 /*! 0008 * \file sink.hpp 0009 * \author Andrey Semashev 0010 * \date 22.04.2007 0011 * 0012 * The header contains an interface declaration for all sinks. This interface is used by the 0013 * logging core to feed log records to sinks. 0014 */ 0015 0016 #ifndef BOOST_LOG_SINKS_SINK_HPP_INCLUDED_ 0017 #define BOOST_LOG_SINKS_SINK_HPP_INCLUDED_ 0018 0019 #include <string> 0020 #include <boost/log/detail/config.hpp> 0021 #include <boost/log/detail/light_function.hpp> 0022 #include <boost/log/core/record_view.hpp> 0023 #include <boost/log/attributes/attribute_value_set.hpp> 0024 #include <boost/log/detail/header.hpp> 0025 0026 #ifdef BOOST_HAS_PRAGMA_ONCE 0027 #pragma once 0028 #endif 0029 0030 namespace boost { 0031 0032 BOOST_LOG_OPEN_NAMESPACE 0033 0034 namespace sinks { 0035 0036 //! A base class for a logging sink frontend 0037 class BOOST_LOG_NO_VTABLE sink 0038 { 0039 public: 0040 //! An exception handler type 0041 typedef boost::log::aux::light_function< void () > exception_handler_type; 0042 0043 private: 0044 //! The flag indicates that the sink passes log records across thread boundaries 0045 const bool m_cross_thread; 0046 0047 public: 0048 /*! 0049 * Default constructor 0050 */ 0051 explicit sink(bool cross_thread) : m_cross_thread(cross_thread) 0052 { 0053 } 0054 0055 /*! 0056 * Virtual destructor 0057 */ 0058 virtual ~sink() {} 0059 0060 /*! 0061 * The method returns \c true if no filter is set or the attribute values pass the filter 0062 * 0063 * \param attributes A set of attribute values of a logging record 0064 */ 0065 virtual bool will_consume(attribute_value_set const& attributes) = 0; 0066 0067 /*! 0068 * The method puts logging record to the sink 0069 * 0070 * \param rec Logging record to consume 0071 */ 0072 virtual void consume(record_view const& rec) = 0; 0073 0074 /*! 0075 * The method attempts to put logging record to the sink. The method may be used by the 0076 * core in order to determine the most efficient order of sinks to feed records to in 0077 * case of heavy contention. Sink implementations may implement try/backoff logic in 0078 * order to improve overall logging throughput. 0079 * 0080 * \param rec Logging record to consume 0081 * \return \c true, if the record was consumed, \c false, if not. 0082 */ 0083 virtual bool try_consume(record_view const& rec) 0084 { 0085 consume(rec); 0086 return true; 0087 } 0088 0089 /*! 0090 * The method performs flushing of any internal buffers that may hold log records. The method 0091 * may take considerable time to complete and may block both the calling thread and threads 0092 * attempting to put new records into the sink while this call is in progress. 0093 */ 0094 virtual void flush() = 0; 0095 0096 /*! 0097 * The method indicates that the sink passes log records between different threads. This information is 0098 * needed by the logging core to detach log records from all thread-specific resources before passing it 0099 * to the sink. 0100 */ 0101 bool is_cross_thread() const BOOST_NOEXCEPT { return m_cross_thread; } 0102 0103 BOOST_DELETED_FUNCTION(sink(sink const&)) 0104 BOOST_DELETED_FUNCTION(sink& operator= (sink const&)) 0105 }; 0106 0107 } // namespace sinks 0108 0109 BOOST_LOG_CLOSE_NAMESPACE // namespace log 0110 0111 } // namespace boost 0112 0113 #include <boost/log/detail/footer.hpp> 0114 0115 #endif // BOOST_LOG_SINKS_SINK_HPP_INCLUDED_
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |