diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-05-05 14:37:58 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-05-05 14:37:58 -0700 |
| commit | 22848e4b7e29a3a74c28afafe4d177e541ec8638 (patch) | |
| tree | 1abfe9818339472b7be7d4812ced3d232da41010 /toolsrc/src | |
| parent | e8c23168fabae9b1426df22ca0a24261959e3b11 (diff) | |
| download | vcpkg-22848e4b7e29a3a74c28afafe4d177e541ec8638.tar.gz vcpkg-22848e4b7e29a3a74c28afafe4d177e541ec8638.zip | |
Introduce Debug::println()
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/vcpkg_Checks.cpp | 6 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_System.cpp | 27 |
2 files changed, 24 insertions, 9 deletions
diff --git a/toolsrc/src/vcpkg_Checks.cpp b/toolsrc/src/vcpkg_Checks.cpp index 817ed895a..2674b889a 100644 --- a/toolsrc/src/vcpkg_Checks.cpp +++ b/toolsrc/src/vcpkg_Checks.cpp @@ -19,11 +19,7 @@ namespace vcpkg::Checks [[noreturn]] void exit_with_code(const LineInfo& line_info, const int exit_code) { - if (g_debugging) - { - System::println(System::Color::error, line_info.to_string()); - } - + Debug::println(System::Color::error, line_info.to_string()); ::exit(exit_code); } diff --git a/toolsrc/src/vcpkg_System.cpp b/toolsrc/src/vcpkg_System.cpp index 00f4a091b..21329e003 100644 --- a/toolsrc/src/vcpkg_System.cpp +++ b/toolsrc/src/vcpkg_System.cpp @@ -115,10 +115,10 @@ namespace vcpkg::System // Basically we are wrapping it in quotes const std::wstring& actual_cmd_line = Strings::wformat(LR"###("%s")###", cmd_line); - if (g_debugging) System::println("[DEBUG] _wspawnlpe(cmd.exe /c %s)", Strings::to_utf8(actual_cmd_line)); + Debug::println("_wspawnlpe(cmd.exe /c %s)", Strings::to_utf8(actual_cmd_line)); auto exit_code = _wspawnlpe(_P_WAIT, L"cmd.exe", L"cmd.exe", L"/c", actual_cmd_line.c_str(), nullptr, env_cstr.data()); - if (g_debugging) System::println("[DEBUG] _wspawnlpe() returned %d", exit_code); + Debug::println("_wspawnlpe() returned %d", exit_code); return static_cast<int>(exit_code); } @@ -129,9 +129,9 @@ namespace vcpkg::System // Basically we are wrapping it in quotes const std::wstring& actual_cmd_line = Strings::wformat(LR"###("%s")###", cmd_line); - if (g_debugging) System::println("[DEBUG] _wsystem(%s)", Strings::to_utf8(actual_cmd_line)); + Debug::println("_wsystem(%s)", Strings::to_utf8(actual_cmd_line)); int exit_code = _wsystem(actual_cmd_line.c_str()); - if (g_debugging) System::println("[DEBUG] _wsystem() returned %d", exit_code); + Debug::println("_wsystem() returned %d", exit_code); return exit_code; } @@ -269,3 +269,22 @@ namespace vcpkg::System return p; } } + +namespace vcpkg::Debug +{ + void println(const CStringView message) + { + if (g_debugging) + { + System::println("[DEBUG] %s", message); + } + } + + void println(const System::Color c, const CStringView message) + { + if (g_debugging) + { + System::println(c, "[DEBUG] %s", message); + } + } +} |
