Hide menu
Loading...
Searching...
No Matches
cadex::Utilities::Logger::Sentry Class Reference

Helper class to unregister the handler from the logger upon own destruction. More...

#include <cadex/Utilities/Logger.hxx>

Public Member Functions

 Sentry (const std::shared_ptr< LoggerHandler > &theHandler)
 Constructor.
 
 ~Sentry ()
 Destructor.
 

Detailed Description

Helper class to unregister the handler from the logger upon own destruction.

Sentry implements the RAII pattern (Resource Acquisition Is Initialization) and is convenient when an handler's life span is limited to a scope, for example:

{
auto aHandler = std::make_shared<LoggerFileHandler> ("myalgorithm.log");
Logger::Sentry aSentry (aHandler);
RunMyAlgorithm();
}
Helper class to unregister the handler from the logger upon own destruction.
Definition Logger.hxx:42