morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::journal::ScopedActionLog Class Reference

RAII helper that installs a default action log for its lifetime and restores the previous one on destruction. More...

#include <action_log.hpp>

Public Member Functions

 ScopedActionLog (std::shared_ptr< IActionLog > log)
 Installs log as the default, saving whatever was there before.
 ~ScopedActionLog ()
 Restores the saved default.
 ScopedActionLog (const ScopedActionLog &)=delete
ScopedActionLog & operator= (const ScopedActionLog &)=delete
 ScopedActionLog (ScopedActionLog &&)=delete
ScopedActionLog & operator= (ScopedActionLog &&)=delete

Detailed Description

RAII helper that installs a default action log for its lifetime and restores the previous one on destruction.

Mirrors morph::log::ScopedLoggerOverride. Intended for tests (so one test case's sink never leaks into the next) and for applications that need to temporarily redirect auto-attached logging within a scope.

{
morph::journal::ScopedActionLog guard{std::make_shared<morph::journal::InMemoryActionLog>(owner)};
// ... models created in this scope auto-attach guard's log ...
} // previous default restored here
RAII helper that installs a default action log for its lifetime and restores the previous one on dest...

Definition at line 437 of file action_log.hpp.

Constructor & Destructor Documentation

◆ ScopedActionLog()

morph::journal::ScopedActionLog::ScopedActionLog ( std::shared_ptr< IActionLog > log)
inlineexplicit

Installs log as the default, saving whatever was there before.

Parameters
logNew default for the lifetime of this object.

Definition at line 441 of file action_log.hpp.

◆ ~ScopedActionLog()

morph::journal::ScopedActionLog::~ScopedActionLog ( )
inline

Restores the saved default.

Definition at line 446 of file action_log.hpp.


The documentation for this class was generated from the following file: