mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-24 12:35:50 +00:00
Improved unit test logging:
Logging from the Application object in the Env is redirected to the suite::log, with the severity level set to error and above.
This commit is contained in:
committed by
Nik Bougalis
parent
5ac744ff66
commit
2be11874e3
@@ -119,17 +119,16 @@ Logs::open (boost::filesystem::path const& pathToLogFile)
|
||||
return file_.open(pathToLogFile);
|
||||
}
|
||||
|
||||
Logs::Sink&
|
||||
beast::Journal::Sink&
|
||||
Logs::get (std::string const& name)
|
||||
{
|
||||
std::lock_guard <std::mutex> lock (mutex_);
|
||||
auto const result (sinks_.emplace (std::piecewise_construct,
|
||||
std::forward_as_tuple(name), std::forward_as_tuple (name,
|
||||
level_, *this)));
|
||||
return result.first->second;
|
||||
auto const result =
|
||||
sinks_.emplace(name, makeSink(name, level_));
|
||||
return *result.first->second;
|
||||
}
|
||||
|
||||
Logs::Sink&
|
||||
beast::Journal::Sink&
|
||||
Logs::operator[] (std::string const& name)
|
||||
{
|
||||
return get(name);
|
||||
@@ -153,7 +152,7 @@ Logs::severity (beast::Journal::Severity level)
|
||||
std::lock_guard <std::mutex> lock (mutex_);
|
||||
level_ = level;
|
||||
for (auto& sink : sinks_)
|
||||
sink.second.severity (level);
|
||||
sink.second->severity (level);
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, std::string>>
|
||||
@@ -164,7 +163,7 @@ Logs::partition_severities() const
|
||||
list.reserve (sinks_.size());
|
||||
for (auto const& e : sinks_)
|
||||
list.push_back(std::make_pair(e.first,
|
||||
toString(fromSeverity(e.second.severity()))));
|
||||
toString(fromSeverity(e.second->severity()))));
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -193,6 +192,14 @@ Logs::rotate()
|
||||
return "The log file could not be closed and reopened.";
|
||||
}
|
||||
|
||||
std::unique_ptr<beast::Journal::Sink>
|
||||
Logs::makeSink(std::string const& name,
|
||||
beast::Journal::Severity startingLevel)
|
||||
{
|
||||
return std::make_unique<Sink>(
|
||||
name, startingLevel, *this);
|
||||
}
|
||||
|
||||
LogSeverity
|
||||
Logs::fromSeverity (beast::Journal::Severity level)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user