CAD Exchanger SDK
cadex::Base_LoggerAppender::Sentry Class Reference

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

Public Member Functions

 Sentry (Base_Logger &theLogger, Base_LoggerAppender &theAppender)
 Constructor.
 
 ~Sentry ()
 Destructor.
 

Detailed Description

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

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

{
Base_Logger& aLogger = Base_Logger::GlobalInstance();
Base_LoggerFileAppender anAppender ("myalgorithm.log");
Base_LoggerAppender::Sentry aSentry (aLogger, anAppender);
RunMyAlgorithm();
}