]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 debug_output_backend.hpp | |
9 | * \author Andrey Semashev | |
10 | * \date 07.11.2008 | |
11 | * | |
12 | * The header contains a logging sink backend that outputs log records to the debugger. | |
13 | */ | |
14 | ||
15 | #ifndef BOOST_LOG_SINKS_DEBUG_OUTPUT_BACKEND_HPP_INCLUDED_ | |
16 | #define BOOST_LOG_SINKS_DEBUG_OUTPUT_BACKEND_HPP_INCLUDED_ | |
17 | ||
18 | #include <string> | |
19 | #include <boost/log/detail/config.hpp> | |
20 | ||
21 | #ifdef BOOST_HAS_PRAGMA_ONCE | |
22 | #pragma once | |
23 | #endif | |
24 | ||
25 | #ifndef BOOST_LOG_WITHOUT_DEBUG_OUTPUT | |
26 | ||
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> | |
32 | ||
33 | namespace boost { | |
34 | ||
35 | BOOST_LOG_OPEN_NAMESPACE | |
36 | ||
37 | namespace sinks { | |
38 | ||
39 | /*! | |
40 | * \brief An implementation of a logging sink backend that outputs to the debugger | |
41 | * | |
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 | |
45 | * formatting. | |
46 | */ | |
47 | template< typename CharT > | |
48 | class basic_debug_output_backend : | |
49 | public basic_formatted_sink_backend< CharT, concurrent_feeding > | |
50 | { | |
51 | //! Base type | |
52 | typedef basic_formatted_sink_backend< CharT, concurrent_feeding > base_type; | |
53 | ||
54 | public: | |
55 | //! Character 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; | |
59 | ||
60 | public: | |
61 | /*! | |
62 | * Constructor. Initializes the sink backend. | |
63 | */ | |
64 | BOOST_LOG_API basic_debug_output_backend(); | |
65 | /*! | |
66 | * Destructor | |
67 | */ | |
68 | BOOST_LOG_API ~basic_debug_output_backend(); | |
69 | ||
70 | /*! | |
71 | * The method passes the formatted message to debugger | |
72 | */ | |
73 | BOOST_LOG_API void consume(record_view const& rec, string_type const& formatted_message); | |
74 | }; | |
75 | ||
76 | #ifdef BOOST_LOG_USE_CHAR | |
77 | typedef basic_debug_output_backend< char > debug_output_backend; //!< Convenience typedef for narrow-character logging | |
78 | #endif | |
79 | #ifdef BOOST_LOG_USE_WCHAR_T | |
80 | typedef basic_debug_output_backend< wchar_t > wdebug_output_backend; //!< Convenience typedef for wide-character logging | |
81 | #endif | |
82 | ||
83 | } // namespace sinks | |
84 | ||
85 | BOOST_LOG_CLOSE_NAMESPACE // namespace log | |
86 | ||
87 | } // namespace boost | |
88 | ||
89 | #include <boost/log/detail/footer.hpp> | |
90 | ||
91 | #endif // BOOST_LOG_WITHOUT_DEBUG_OUTPUT | |
92 | ||
93 | #endif // BOOST_LOG_SINKS_DEBUG_OUTPUT_BACKEND_HPP_INCLUDED_ |