• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.cpp
9  * \author Andrey Semashev
10  * \date   08.11.2008
11  *
12  * \brief  A logging sink backend that uses debugger output
13  */
14 
15 #include <boost/log/detail/config.hpp>
16 
17 #ifndef BOOST_LOG_WITHOUT_DEBUG_OUTPUT
18 
19 #include <string>
20 #include <boost/log/sinks/debug_output_backend.hpp>
21 #include <windows.h>
22 #include <boost/log/detail/header.hpp>
23 
24 namespace boost {
25 
26 BOOST_LOG_OPEN_NAMESPACE
27 
28 namespace sinks {
29 
30 BOOST_LOG_ANONYMOUS_NAMESPACE {
31 
32 #if defined(BOOST_LOG_USE_CHAR)
33     inline void output_debug_string(const char* str)
34     {
35         OutputDebugStringA(str);
36     }
37 #endif // defined(BOOST_LOG_USE_CHAR)
38 #if defined(BOOST_LOG_USE_WCHAR_T)
39     inline void output_debug_string(const wchar_t* str)
40     {
41         OutputDebugStringW(str);
42     }
43 #endif // defined(BOOST_LOG_USE_WCHAR_T)
44 
45 } // namespace
46 
47 template< typename CharT >
48 BOOST_LOG_API basic_debug_output_backend< CharT >::basic_debug_output_backend()
49 {
50 }
51 
52 template< typename CharT >
~basic_debug_output_backend()53 BOOST_LOG_API basic_debug_output_backend< CharT >::~basic_debug_output_backend()
54 {
55 }
56 
57 //! The method puts the formatted message to the event log
58 template< typename CharT >
consume(record_view const &,string_type const & formatted_message)59 BOOST_LOG_API void basic_debug_output_backend< CharT >::consume(record_view const&, string_type const& formatted_message)
60 {
61     output_debug_string(formatted_message.c_str());
62 }
63 
64 #ifdef BOOST_LOG_USE_CHAR
65 template class basic_debug_output_backend< char >;
66 #endif
67 #ifdef BOOST_LOG_USE_WCHAR_T
68 template class basic_debug_output_backend< wchar_t >;
69 #endif
70 
71 } // namespace sinks
72 
73 BOOST_LOG_CLOSE_NAMESPACE // namespace log
74 
75 } // namespace boost
76 
77 #include <boost/log/detail/footer.hpp>
78 
79 #endif // !defined(BOOST_LOG_WITHOUT_DEBUG_OUTPUT)
80