mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-01-16 21:38:12 +08:00
Introduce Debug::println()
This commit is contained in:
parent
e8c23168fa
commit
22848e4b7e
@ -40,25 +40,25 @@ namespace vcpkg::System
|
||||
template<class Arg1, class... Args>
|
||||
void print(const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs)
|
||||
{
|
||||
return print(Strings::format(messageTemplate, messageArg1, messageArgs...));
|
||||
return System::print(Strings::format(messageTemplate, messageArg1, messageArgs...));
|
||||
}
|
||||
|
||||
template<class Arg1, class... Args>
|
||||
void print(const Color c, const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs)
|
||||
{
|
||||
return print(c, Strings::format(messageTemplate, messageArg1, messageArgs...));
|
||||
return System::print(c, Strings::format(messageTemplate, messageArg1, messageArgs...));
|
||||
}
|
||||
|
||||
template<class Arg1, class... Args>
|
||||
void println(const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs)
|
||||
{
|
||||
return println(Strings::format(messageTemplate, messageArg1, messageArgs...));
|
||||
return System::println(Strings::format(messageTemplate, messageArg1, messageArgs...));
|
||||
}
|
||||
|
||||
template<class Arg1, class... Args>
|
||||
void println(const Color c, const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs)
|
||||
{
|
||||
return println(c, Strings::format(messageTemplate, messageArg1, messageArgs...));
|
||||
return System::println(c, Strings::format(messageTemplate, messageArg1, messageArgs...));
|
||||
}
|
||||
|
||||
Optional<std::wstring> get_environment_variable(const CWStringView varname) noexcept;
|
||||
@ -81,3 +81,24 @@ namespace vcpkg::System
|
||||
|
||||
const fs::path& get_ProgramFiles_platform_bitness();
|
||||
}
|
||||
|
||||
namespace vcpkg::Debug
|
||||
{
|
||||
void println(const CStringView message);
|
||||
void println(const System::Color c, const CStringView message);
|
||||
|
||||
template<class Arg1, class... Args>
|
||||
void println(const char* messageTemplate, const Arg1& messageArg1, const Args&... messageArgs)
|
||||
{
|
||||
return Debug::println(Strings::format(messageTemplate, messageArg1, messageArgs...));
|
||||
}
|
||||
|
||||
template<class Arg1, class... Args>
|
||||
void println(const System::Color c,
|
||||
const char* messageTemplate,
|
||||
const Arg1& messageArg1,
|
||||
const Args&... messageArgs)
|
||||
{
|
||||
return Debug::println(c, Strings::format(messageTemplate, messageArg1, messageArgs...));
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user