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)
8 * \file debug_output_backend.hpp
9 * \author Andrey Semashev
12 * The header contains a logging sink backend that outputs log records to the debugger.
15 #ifndef BOOST_LOG_SINKS_DEBUG_OUTPUT_BACKEND_HPP_INCLUDED_
16 #define BOOST_LOG_SINKS_DEBUG_OUTPUT_BACKEND_HPP_INCLUDED_
19 #include <boost/log/detail/config.hpp>
21 #ifdef BOOST_HAS_PRAGMA_ONCE
25 #ifndef BOOST_LOG_WITHOUT_DEBUG_OUTPUT
27 #include <boost/log/sinks/basic_sink_backend.hpp>
28 #include <boost/log/sinks/frontend_requirements.hpp>
29 #include <boost/log/attributes/attribute_value_set.hpp>
30 #include <boost/log/core/record_view.hpp>
31 #include <boost/log/detail/header.hpp>
35 BOOST_LOG_OPEN_NAMESPACE
40 * \brief An implementation of a logging sink backend that outputs to the debugger
42 * The sink uses Windows API in order to write log records as debug messages, if the
43 * application process is run under debugger. The sink backend also provides a specific
44 * filter that allows to check whether the debugger is available and thus elide unnecessary
47 template< typename CharT >
48 class basic_debug_output_backend :
49 public basic_formatted_sink_backend< CharT, concurrent_feeding >
52 typedef basic_formatted_sink_backend< CharT, concurrent_feeding > base_type;
56 typedef typename base_type::char_type char_type;
57 //! String type to be used as a message text holder
58 typedef typename base_type::string_type string_type;
62 * Constructor. Initializes the sink backend.
64 BOOST_LOG_API basic_debug_output_backend();
68 BOOST_LOG_API ~basic_debug_output_backend();
71 * The method passes the formatted message to debugger
73 BOOST_LOG_API void consume(record_view const& rec, string_type const& formatted_message);
76 #ifdef BOOST_LOG_USE_CHAR
77 typedef basic_debug_output_backend< char > debug_output_backend; //!< Convenience typedef for narrow-character logging
79 #ifdef BOOST_LOG_USE_WCHAR_T
80 typedef basic_debug_output_backend< wchar_t > wdebug_output_backend; //!< Convenience typedef for wide-character logging
85 BOOST_LOG_CLOSE_NAMESPACE // namespace log
89 #include <boost/log/detail/footer.hpp>
91 #endif // BOOST_LOG_WITHOUT_DEBUG_OUTPUT
93 #endif // BOOST_LOG_SINKS_DEBUG_OUTPUT_BACKEND_HPP_INCLUDED_