Chris@16
|
1 /*
|
Chris@101
|
2 * Copyright Andrey Semashev 2007 - 2015.
|
Chris@16
|
3 * Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
4 * (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
5 * http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 */
|
Chris@16
|
7 /*!
|
Chris@16
|
8 * \file debug_output_backend.hpp
|
Chris@16
|
9 * \author Andrey Semashev
|
Chris@16
|
10 * \date 07.11.2008
|
Chris@16
|
11 *
|
Chris@16
|
12 * The header contains a logging sink backend that outputs log records to the debugger.
|
Chris@16
|
13 */
|
Chris@16
|
14
|
Chris@16
|
15 #ifndef BOOST_LOG_SINKS_DEBUG_OUTPUT_BACKEND_HPP_INCLUDED_
|
Chris@16
|
16 #define BOOST_LOG_SINKS_DEBUG_OUTPUT_BACKEND_HPP_INCLUDED_
|
Chris@16
|
17
|
Chris@16
|
18 #include <string>
|
Chris@16
|
19 #include <boost/log/detail/config.hpp>
|
Chris@16
|
20
|
Chris@16
|
21 #ifdef BOOST_HAS_PRAGMA_ONCE
|
Chris@16
|
22 #pragma once
|
Chris@16
|
23 #endif
|
Chris@16
|
24
|
Chris@16
|
25 #ifndef BOOST_LOG_WITHOUT_DEBUG_OUTPUT
|
Chris@16
|
26
|
Chris@16
|
27 #include <boost/log/sinks/basic_sink_backend.hpp>
|
Chris@16
|
28 #include <boost/log/sinks/frontend_requirements.hpp>
|
Chris@16
|
29 #include <boost/log/attributes/attribute_value_set.hpp>
|
Chris@16
|
30 #include <boost/log/core/record_view.hpp>
|
Chris@16
|
31 #include <boost/log/detail/header.hpp>
|
Chris@16
|
32
|
Chris@16
|
33 namespace boost {
|
Chris@16
|
34
|
Chris@16
|
35 BOOST_LOG_OPEN_NAMESPACE
|
Chris@16
|
36
|
Chris@16
|
37 namespace sinks {
|
Chris@16
|
38
|
Chris@16
|
39 /*!
|
Chris@16
|
40 * \brief An implementation of a logging sink backend that outputs to the debugger
|
Chris@16
|
41 *
|
Chris@16
|
42 * The sink uses Windows API in order to write log records as debug messages, if the
|
Chris@16
|
43 * application process is run under debugger. The sink backend also provides a specific
|
Chris@16
|
44 * filter that allows to check whether the debugger is available and thus elide unnecessary
|
Chris@16
|
45 * formatting.
|
Chris@16
|
46 */
|
Chris@16
|
47 template< typename CharT >
|
Chris@16
|
48 class basic_debug_output_backend :
|
Chris@16
|
49 public basic_formatted_sink_backend< CharT, concurrent_feeding >
|
Chris@16
|
50 {
|
Chris@16
|
51 //! Base type
|
Chris@16
|
52 typedef basic_formatted_sink_backend< CharT, concurrent_feeding > base_type;
|
Chris@16
|
53
|
Chris@16
|
54 public:
|
Chris@16
|
55 //! Character type
|
Chris@16
|
56 typedef typename base_type::char_type char_type;
|
Chris@16
|
57 //! String type to be used as a message text holder
|
Chris@16
|
58 typedef typename base_type::string_type string_type;
|
Chris@16
|
59
|
Chris@16
|
60 public:
|
Chris@16
|
61 /*!
|
Chris@16
|
62 * Constructor. Initializes the sink backend.
|
Chris@16
|
63 */
|
Chris@16
|
64 BOOST_LOG_API basic_debug_output_backend();
|
Chris@16
|
65 /*!
|
Chris@16
|
66 * Destructor
|
Chris@16
|
67 */
|
Chris@16
|
68 BOOST_LOG_API ~basic_debug_output_backend();
|
Chris@16
|
69
|
Chris@16
|
70 /*!
|
Chris@16
|
71 * The method passes the formatted message to debugger
|
Chris@16
|
72 */
|
Chris@16
|
73 BOOST_LOG_API void consume(record_view const& rec, string_type const& formatted_message);
|
Chris@16
|
74 };
|
Chris@16
|
75
|
Chris@16
|
76 #ifdef BOOST_LOG_USE_CHAR
|
Chris@16
|
77 typedef basic_debug_output_backend< char > debug_output_backend; //!< Convenience typedef for narrow-character logging
|
Chris@16
|
78 #endif
|
Chris@16
|
79 #ifdef BOOST_LOG_USE_WCHAR_T
|
Chris@16
|
80 typedef basic_debug_output_backend< wchar_t > wdebug_output_backend; //!< Convenience typedef for wide-character logging
|
Chris@16
|
81 #endif
|
Chris@16
|
82
|
Chris@16
|
83 } // namespace sinks
|
Chris@16
|
84
|
Chris@16
|
85 BOOST_LOG_CLOSE_NAMESPACE // namespace log
|
Chris@16
|
86
|
Chris@16
|
87 } // namespace boost
|
Chris@16
|
88
|
Chris@16
|
89 #include <boost/log/detail/footer.hpp>
|
Chris@16
|
90
|
Chris@16
|
91 #endif // BOOST_LOG_WITHOUT_DEBUG_OUTPUT
|
Chris@16
|
92
|
Chris@16
|
93 #endif // BOOST_LOG_SINKS_DEBUG_OUTPUT_BACKEND_HPP_INCLUDED_
|