Chris@16: /* Chris@101: * Copyright Andrey Semashev 2007 - 2015. Chris@16: * Distributed under the Boost Software License, Version 1.0. Chris@16: * (See accompanying file LICENSE_1_0.txt or copy at Chris@16: * http://www.boost.org/LICENSE_1_0.txt) Chris@16: */ Chris@16: /*! Chris@16: * \file debug_output_backend.hpp Chris@16: * \author Andrey Semashev Chris@16: * \date 07.11.2008 Chris@16: * Chris@16: * The header contains a logging sink backend that outputs log records to the debugger. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_LOG_SINKS_DEBUG_OUTPUT_BACKEND_HPP_INCLUDED_ Chris@16: #define BOOST_LOG_SINKS_DEBUG_OUTPUT_BACKEND_HPP_INCLUDED_ Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: #ifdef BOOST_HAS_PRAGMA_ONCE Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@16: #ifndef BOOST_LOG_WITHOUT_DEBUG_OUTPUT Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: BOOST_LOG_OPEN_NAMESPACE Chris@16: Chris@16: namespace sinks { Chris@16: Chris@16: /*! Chris@16: * \brief An implementation of a logging sink backend that outputs to the debugger Chris@16: * Chris@16: * The sink uses Windows API in order to write log records as debug messages, if the Chris@16: * application process is run under debugger. The sink backend also provides a specific Chris@16: * filter that allows to check whether the debugger is available and thus elide unnecessary Chris@16: * formatting. Chris@16: */ Chris@16: template< typename CharT > Chris@16: class basic_debug_output_backend : Chris@16: public basic_formatted_sink_backend< CharT, concurrent_feeding > Chris@16: { Chris@16: //! Base type Chris@16: typedef basic_formatted_sink_backend< CharT, concurrent_feeding > base_type; Chris@16: Chris@16: public: Chris@16: //! Character type Chris@16: typedef typename base_type::char_type char_type; Chris@16: //! String type to be used as a message text holder Chris@16: typedef typename base_type::string_type string_type; Chris@16: Chris@16: public: Chris@16: /*! Chris@16: * Constructor. Initializes the sink backend. Chris@16: */ Chris@16: BOOST_LOG_API basic_debug_output_backend(); Chris@16: /*! Chris@16: * Destructor Chris@16: */ Chris@16: BOOST_LOG_API ~basic_debug_output_backend(); Chris@16: Chris@16: /*! Chris@16: * The method passes the formatted message to debugger Chris@16: */ Chris@16: BOOST_LOG_API void consume(record_view const& rec, string_type const& formatted_message); Chris@16: }; Chris@16: Chris@16: #ifdef BOOST_LOG_USE_CHAR Chris@16: typedef basic_debug_output_backend< char > debug_output_backend; //!< Convenience typedef for narrow-character logging Chris@16: #endif Chris@16: #ifdef BOOST_LOG_USE_WCHAR_T Chris@16: typedef basic_debug_output_backend< wchar_t > wdebug_output_backend; //!< Convenience typedef for wide-character logging Chris@16: #endif Chris@16: Chris@16: } // namespace sinks Chris@16: Chris@16: BOOST_LOG_CLOSE_NAMESPACE // namespace log Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // BOOST_LOG_WITHOUT_DEBUG_OUTPUT Chris@16: Chris@16: #endif // BOOST_LOG_SINKS_DEBUG_OUTPUT_BACKEND_HPP_INCLUDED_