mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-30 18:29:37 -06:00
ConfigureLog: De-duplicate event backtrace and check key generation
All event kinds have these fields, so centralize their implementation.
This commit is contained in:
@@ -136,7 +136,7 @@ void cmConfigureLog::EndObject()
|
||||
--this->Indent;
|
||||
}
|
||||
|
||||
void cmConfigureLog::BeginEvent(std::string const& kind)
|
||||
void cmConfigureLog::BeginEvent(std::string const& kind, cmMakefile const& mf)
|
||||
{
|
||||
this->EnsureInit();
|
||||
|
||||
@@ -146,6 +146,8 @@ void cmConfigureLog::BeginEvent(std::string const& kind)
|
||||
++this->Indent;
|
||||
|
||||
this->WriteValue("kind"_s, kind);
|
||||
this->WriteBacktrace(mf);
|
||||
this->WriteChecks(mf);
|
||||
}
|
||||
|
||||
void cmConfigureLog::EndEvent()
|
||||
|
||||
@@ -28,12 +28,9 @@ public:
|
||||
list is enabled. */
|
||||
bool IsAnyLogVersionEnabled(std::vector<unsigned long> const& v) const;
|
||||
|
||||
void WriteBacktrace(cmMakefile const& mf);
|
||||
void WriteChecks(cmMakefile const& mf);
|
||||
|
||||
void EnsureInit();
|
||||
|
||||
void BeginEvent(std::string const& kind);
|
||||
void BeginEvent(std::string const& kind, cmMakefile const& mf);
|
||||
void EndEvent();
|
||||
|
||||
void BeginObject(cm::string_view key);
|
||||
@@ -63,6 +60,9 @@ private:
|
||||
|
||||
std::unique_ptr<Json::StreamWriter> Encoder;
|
||||
|
||||
void WriteBacktrace(cmMakefile const& mf);
|
||||
void WriteChecks(cmMakefile const& mf);
|
||||
|
||||
cmsys::ofstream& BeginLine();
|
||||
void EndLine();
|
||||
void WriteEscape(unsigned char c);
|
||||
|
||||
@@ -74,9 +74,7 @@ void WriteMessageEvent(cmConfigureLog& log, cmMakefile const& mf,
|
||||
static const std::vector<unsigned long> LogVersionsWithMessageV1{ 1 };
|
||||
|
||||
if (log.IsAnyLogVersionEnabled(LogVersionsWithMessageV1)) {
|
||||
log.BeginEvent("message-v1");
|
||||
log.WriteBacktrace(mf);
|
||||
log.WriteChecks(mf);
|
||||
log.BeginEvent("message-v1", mf);
|
||||
log.WriteLiteralTextBlock("message"_s, message);
|
||||
log.EndEvent();
|
||||
}
|
||||
|
||||
@@ -25,9 +25,7 @@ void WriteTryCompileEvent(cmConfigureLog& log, cmMakefile const& mf,
|
||||
static const std::vector<unsigned long> LogVersionsWithTryCompileV1{ 1 };
|
||||
|
||||
if (log.IsAnyLogVersionEnabled(LogVersionsWithTryCompileV1)) {
|
||||
log.BeginEvent("try_compile-v1");
|
||||
log.WriteBacktrace(mf);
|
||||
log.WriteChecks(mf);
|
||||
log.BeginEvent("try_compile-v1", mf);
|
||||
cmCoreTryCompile::WriteTryCompileEventFields(log, compileResult);
|
||||
log.EndEvent();
|
||||
}
|
||||
|
||||
@@ -44,9 +44,7 @@ void WriteTryRunEvent(cmConfigureLog& log, cmMakefile const& mf,
|
||||
static const std::vector<unsigned long> LogVersionsWithTryRunV1{ 1 };
|
||||
|
||||
if (log.IsAnyLogVersionEnabled(LogVersionsWithTryRunV1)) {
|
||||
log.BeginEvent("try_run-v1");
|
||||
log.WriteBacktrace(mf);
|
||||
log.WriteChecks(mf);
|
||||
log.BeginEvent("try_run-v1", mf);
|
||||
cmCoreTryCompile::WriteTryCompileEventFields(log, compileResult);
|
||||
|
||||
log.BeginObject("runResult"_s);
|
||||
|
||||
Reference in New Issue
Block a user