mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-22 16:07:49 +08:00
Autogen: Let cmQtAutoGenerator::Logger methods accept cm::string_view
This commit is contained in:
@@ -58,18 +58,16 @@ void cmQtAutoGenerator::Logger::SetColorOutput(bool value)
|
|||||||
ColorOutput_ = value;
|
ColorOutput_ = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cmQtAutoGenerator::Logger::HeadLine(std::string const& title)
|
std::string cmQtAutoGenerator::Logger::HeadLine(cm::string_view title)
|
||||||
{
|
{
|
||||||
return cmStrCat(title, "\n", std::string(title.size(), '-'), "\n");
|
return cmStrCat(title, '\n', std::string(title.size(), '-'), '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmQtAutoGenerator::Logger::Info(GenT genType,
|
void cmQtAutoGenerator::Logger::Info(GenT genType,
|
||||||
std::string const& message) const
|
cm::string_view message) const
|
||||||
{
|
{
|
||||||
std::string msg = cmStrCat(GeneratorName(genType), ": ", message);
|
std::string msg = cmStrCat(GeneratorName(genType), ": ", message,
|
||||||
if (msg.back() != '\n') {
|
cmHasSuffix(message, '\n') ? "" : "\n");
|
||||||
msg.push_back('\n');
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(Mutex_);
|
std::lock_guard<std::mutex> lock(Mutex_);
|
||||||
cmSystemTools::Stdout(msg);
|
cmSystemTools::Stdout(msg);
|
||||||
@@ -77,23 +75,18 @@ void cmQtAutoGenerator::Logger::Info(GenT genType,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cmQtAutoGenerator::Logger::Warning(GenT genType,
|
void cmQtAutoGenerator::Logger::Warning(GenT genType,
|
||||||
std::string const& message) const
|
cm::string_view message) const
|
||||||
{
|
{
|
||||||
std::string msg;
|
std::string msg;
|
||||||
if (message.find('\n') == std::string::npos) {
|
if (message.find('\n') == std::string::npos) {
|
||||||
// Single line message
|
// Single line message
|
||||||
msg += GeneratorName(genType);
|
msg = cmStrCat(GeneratorName(genType), " warning: ", message,
|
||||||
msg += " warning: ";
|
cmHasSuffix(message, '\n') ? "\n" : "\n\n");
|
||||||
} else {
|
} else {
|
||||||
// Multi line message
|
// Multi line message
|
||||||
msg += HeadLine(cmStrCat(GeneratorName(genType), " warning"));
|
msg = cmStrCat(HeadLine(cmStrCat(GeneratorName(genType), " warning")),
|
||||||
|
message, cmHasSuffix(message, '\n') ? "\n" : "\n\n");
|
||||||
}
|
}
|
||||||
// Message
|
|
||||||
msg += message;
|
|
||||||
if (msg.back() != '\n') {
|
|
||||||
msg.push_back('\n');
|
|
||||||
}
|
|
||||||
msg.push_back('\n');
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(Mutex_);
|
std::lock_guard<std::mutex> lock(Mutex_);
|
||||||
cmSystemTools::Stdout(msg);
|
cmSystemTools::Stdout(msg);
|
||||||
@@ -101,22 +94,18 @@ void cmQtAutoGenerator::Logger::Warning(GenT genType,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cmQtAutoGenerator::Logger::WarningFile(GenT genType,
|
void cmQtAutoGenerator::Logger::WarningFile(GenT genType,
|
||||||
std::string const& filename,
|
cm::string_view filename,
|
||||||
std::string const& message) const
|
cm::string_view message) const
|
||||||
{
|
{
|
||||||
Warning(genType, cmStrCat(" ", Quoted(filename), "\n", message));
|
Warning(genType, cmStrCat(" ", Quoted(filename), '\n', message));
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmQtAutoGenerator::Logger::Error(GenT genType,
|
void cmQtAutoGenerator::Logger::Error(GenT genType,
|
||||||
std::string const& message) const
|
cm::string_view message) const
|
||||||
{
|
{
|
||||||
std::string msg = HeadLine(cmStrCat(GeneratorName(genType), " error"));
|
std::string msg =
|
||||||
// Message
|
cmStrCat(HeadLine(cmStrCat(GeneratorName(genType), " error")), message,
|
||||||
msg += message;
|
cmHasSuffix(message, '\n') ? "\n" : "\n\n");
|
||||||
if (msg.back() != '\n') {
|
|
||||||
msg.push_back('\n');
|
|
||||||
}
|
|
||||||
msg.push_back('\n');
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(Mutex_);
|
std::lock_guard<std::mutex> lock(Mutex_);
|
||||||
cmSystemTools::Stderr(msg);
|
cmSystemTools::Stderr(msg);
|
||||||
@@ -124,36 +113,22 @@ void cmQtAutoGenerator::Logger::Error(GenT genType,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cmQtAutoGenerator::Logger::ErrorFile(GenT genType,
|
void cmQtAutoGenerator::Logger::ErrorFile(GenT genType,
|
||||||
std::string const& filename,
|
cm::string_view filename,
|
||||||
std::string const& message) const
|
cm::string_view message) const
|
||||||
{
|
{
|
||||||
Error(genType, cmStrCat(" ", Quoted(filename), '\n', message));
|
Error(genType, cmStrCat(" ", Quoted(filename), '\n', message));
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmQtAutoGenerator::Logger::ErrorCommand(
|
void cmQtAutoGenerator::Logger::ErrorCommand(
|
||||||
GenT genType, std::string const& message,
|
GenT genType, cm::string_view message,
|
||||||
std::vector<std::string> const& command, std::string const& output) const
|
std::vector<std::string> const& command, std::string const& output) const
|
||||||
{
|
{
|
||||||
std::string msg;
|
std::string msg = cmStrCat(
|
||||||
msg.push_back('\n');
|
'\n', HeadLine(cmStrCat(GeneratorName(genType), " subprocess error")),
|
||||||
msg += HeadLine(cmStrCat(GeneratorName(genType), " subprocess error"));
|
message, cmHasSuffix(message, '\n') ? "\n" : "\n\n");
|
||||||
msg += message;
|
msg += cmStrCat(HeadLine("Command"), QuotedCommand(command), "\n\n");
|
||||||
if (msg.back() != '\n') {
|
msg += cmStrCat(HeadLine("Output"), output,
|
||||||
msg.push_back('\n');
|
cmHasSuffix(output, '\n') ? "\n" : "\n\n");
|
||||||
}
|
|
||||||
msg.push_back('\n');
|
|
||||||
msg += HeadLine("Command");
|
|
||||||
msg += QuotedCommand(command);
|
|
||||||
if (msg.back() != '\n') {
|
|
||||||
msg.push_back('\n');
|
|
||||||
}
|
|
||||||
msg.push_back('\n');
|
|
||||||
msg += HeadLine("Output");
|
|
||||||
msg += output;
|
|
||||||
if (msg.back() != '\n') {
|
|
||||||
msg.push_back('\n');
|
|
||||||
}
|
|
||||||
msg.push_back('\n');
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(Mutex_);
|
std::lock_guard<std::mutex> lock(Mutex_);
|
||||||
cmSystemTools::Stderr(msg);
|
cmSystemTools::Stderr(msg);
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "cmFileTime.h"
|
#include "cmFileTime.h"
|
||||||
#include "cmQtAutoGen.h"
|
#include "cmQtAutoGen.h"
|
||||||
|
#include "cm_string_view.hxx"
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -41,21 +42,21 @@ public:
|
|||||||
bool ColorOutput() const { return this->ColorOutput_; }
|
bool ColorOutput() const { return this->ColorOutput_; }
|
||||||
void SetColorOutput(bool value);
|
void SetColorOutput(bool value);
|
||||||
// -- Log info
|
// -- Log info
|
||||||
void Info(GenT genType, std::string const& message) const;
|
void Info(GenT genType, cm::string_view message) const;
|
||||||
// -- Log warning
|
// -- Log warning
|
||||||
void Warning(GenT genType, std::string const& message) const;
|
void Warning(GenT genType, cm::string_view message) const;
|
||||||
void WarningFile(GenT genType, std::string const& filename,
|
void WarningFile(GenT genType, cm::string_view filename,
|
||||||
std::string const& message) const;
|
cm::string_view message) const;
|
||||||
// -- Log error
|
// -- Log error
|
||||||
void Error(GenT genType, std::string const& message) const;
|
void Error(GenT genType, cm::string_view message) const;
|
||||||
void ErrorFile(GenT genType, std::string const& filename,
|
void ErrorFile(GenT genType, cm::string_view filename,
|
||||||
std::string const& message) const;
|
cm::string_view message) const;
|
||||||
void ErrorCommand(GenT genType, std::string const& message,
|
void ErrorCommand(GenT genType, cm::string_view message,
|
||||||
std::vector<std::string> const& command,
|
std::vector<std::string> const& command,
|
||||||
std::string const& output) const;
|
std::string const& output) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::string HeadLine(std::string const& title);
|
static std::string HeadLine(cm::string_view title);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable std::mutex Mutex_;
|
mutable std::mutex Mutex_;
|
||||||
|
Reference in New Issue
Block a user