/ externals / catch / src / catch2 / internal / catch_debug_console.cpp
catch_debug_console.cpp
 1  
 2  //              Copyright Catch2 Authors
 3  // Distributed under the Boost Software License, Version 1.0.
 4  //   (See accompanying file LICENSE.txt or copy at
 5  //        https://www.boost.org/LICENSE_1_0.txt)
 6  
 7  // SPDX-License-Identifier: BSL-1.0
 8  
 9  #include <catch2/internal/catch_debug_console.hpp>
10  
11  #include <catch2/internal/catch_config_android_logwrite.hpp>
12  #include <catch2/internal/catch_platform.hpp>
13  #include <catch2/internal/catch_windows_h_proxy.hpp>
14  #include <catch2/catch_user_config.hpp>
15  #include <catch2/internal/catch_stdstreams.hpp>
16  
17  #include <ostream>
18  
19  #if defined(CATCH_CONFIG_ANDROID_LOGWRITE)
20  #include <android/log.h>
21  
22      namespace Catch {
23          void writeToDebugConsole( std::string const& text ) {
24              __android_log_write( ANDROID_LOG_DEBUG, "Catch", text.c_str() );
25          }
26      }
27  
28  #elif defined(CATCH_PLATFORM_WINDOWS)
29  
30      namespace Catch {
31          void writeToDebugConsole( std::string const& text ) {
32              ::OutputDebugStringA( text.c_str() );
33          }
34      }
35  
36  #else
37  
38      namespace Catch {
39          void writeToDebugConsole( std::string const& text ) {
40              // !TBD: Need a version for Mac/ XCode and other IDEs
41              Catch::cout() << text;
42          }
43      }
44  
45  #endif // Platform