mirror of
https://github.com/NixOS/nix
synced 2025-06-30 19:57:59 +02:00
refactor: RAII logger suspension
(cherry picked from commit 30694b5d8a
)
This commit is contained in:
parent
375df6c086
commit
ac3fc8876c
7 changed files with 46 additions and 35 deletions
|
@ -43,6 +43,19 @@ void Logger::writeToStdout(std::string_view s)
|
|||
writeFull(standard_out, "\n");
|
||||
}
|
||||
|
||||
Logger::Suspension Logger::suspend()
|
||||
{
|
||||
pause();
|
||||
return Suspension { ._finalize = {[this](){this->resume();}} };
|
||||
}
|
||||
|
||||
std::optional<Logger::Suspension> Logger::suspendIf(bool cond)
|
||||
{
|
||||
if (cond)
|
||||
return suspend();
|
||||
return {};
|
||||
}
|
||||
|
||||
class SimpleLogger : public Logger
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue