]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/log/include/boost/log/sinks/text_ostream_backend.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / log / include / boost / log / sinks / text_ostream_backend.hpp
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 text_ostream_backend.hpp
9 * \author Andrey Semashev
10 * \date 22.04.2007
11 *
12 * The header contains implementation of a text output stream sink backend.
13 */
14
15 #ifndef BOOST_LOG_SINKS_TEXT_OSTREAM_BACKEND_HPP_INCLUDED_
16 #define BOOST_LOG_SINKS_TEXT_OSTREAM_BACKEND_HPP_INCLUDED_
17
18 #include <ostream>
19 #include <boost/smart_ptr/shared_ptr.hpp>
20 #include <boost/log/detail/config.hpp>
21 #include <boost/log/sinks/basic_sink_backend.hpp>
22 #include <boost/log/sinks/frontend_requirements.hpp>
23 #include <boost/log/detail/header.hpp>
24
25 #ifdef BOOST_HAS_PRAGMA_ONCE
26 #pragma once
27 #endif
28
29 namespace boost {
30
31 BOOST_LOG_OPEN_NAMESPACE
32
33 namespace sinks {
34
35 /*!
36 * \brief An implementation of a text output stream logging sink backend
37 *
38 * The sink backend puts formatted log records to one or more text streams.
39 */
40 template< typename CharT >
41 class basic_text_ostream_backend :
42 public basic_formatted_sink_backend<
43 CharT,
44 combine_requirements< synchronized_feeding, flushing >::type
45 >
46 {
47 //! Base type
48 typedef basic_formatted_sink_backend<
49 CharT,
50 combine_requirements< synchronized_feeding, flushing >::type
51 > base_type;
52
53 public:
54 //! Character type
55 typedef typename base_type::char_type char_type;
56 //! String type to be used as a message text holder
57 typedef typename base_type::string_type string_type;
58 //! Output stream type
59 typedef std::basic_ostream< char_type > stream_type;
60
61 private:
62 //! \cond
63
64 struct implementation;
65 implementation* m_pImpl;
66
67 //! \endcond
68
69 public:
70 /*!
71 * Constructor. No streams attached to the constructed backend, auto flush feature disabled.
72 */
73 BOOST_LOG_API basic_text_ostream_backend();
74 /*!
75 * Destructor
76 */
77 BOOST_LOG_API ~basic_text_ostream_backend();
78
79 /*!
80 * The method adds a new stream to the sink.
81 *
82 * \param strm Pointer to the stream. Must not be NULL.
83 */
84 BOOST_LOG_API void add_stream(shared_ptr< stream_type > const& strm);
85 /*!
86 * The method removes a stream from the sink. If the stream is not attached to the sink,
87 * the method has no effect.
88 *
89 * \param strm Pointer to the stream. Must not be NULL.
90 */
91 BOOST_LOG_API void remove_stream(shared_ptr< stream_type > const& strm);
92
93 /*!
94 * Sets the flag to automatically flush buffers of all attached streams after each log record
95 */
96 BOOST_LOG_API void auto_flush(bool f = true);
97
98 /*!
99 * The method writes the message to the sink
100 */
101 BOOST_LOG_API void consume(record_view const& rec, string_type const& formatted_message);
102
103 /*!
104 * The method flushes the associated streams
105 */
106 BOOST_LOG_API void flush();
107 };
108
109 #ifdef BOOST_LOG_USE_CHAR
110 typedef basic_text_ostream_backend< char > text_ostream_backend; //!< Convenience typedef for narrow-character logging
111 #endif
112 #ifdef BOOST_LOG_USE_WCHAR_T
113 typedef basic_text_ostream_backend< wchar_t > wtext_ostream_backend; //!< Convenience typedef for wide-character logging
114 #endif
115
116 } // namespace sinks
117
118 BOOST_LOG_CLOSE_NAMESPACE // namespace log
119
120 } // namespace boost
121
122 #include <boost/log/detail/footer.hpp>
123
124 #endif // BOOST_LOG_SINKS_TEXT_OSTREAM_BACKEND_HPP_INCLUDED_