diff options
author | Brad Kittenbrink <brad@lindenlab.com> | 2009-06-04 16:24:21 +0000 |
---|---|---|
committer | Brad Kittenbrink <brad@lindenlab.com> | 2009-06-04 16:24:21 +0000 |
commit | 087bd265534b8e3086ae1af441a9cf0eb7c684df (patch) | |
tree | a0c911515476d4ac4aac9bd984de28eb7573a478 /indra/llcommon/llerrorcontrol.h | |
parent | f9b9372027a41900ad572afcd7ea0d2cc5489b8f (diff) |
Merge of QAR-1383 event-system-7 into trunk.
svn merge -r 121797:121853 svn+ssh://svn.lindenlab.com/svn/linden/branches/merge-event-system-7
Diffstat (limited to 'indra/llcommon/llerrorcontrol.h')
-rw-r--r-- | indra/llcommon/llerrorcontrol.h | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/indra/llcommon/llerrorcontrol.h b/indra/llcommon/llerrorcontrol.h index a55d706d2e..c9424f8a5e 100644 --- a/indra/llcommon/llerrorcontrol.h +++ b/indra/llcommon/llerrorcontrol.h @@ -35,7 +35,7 @@ #define LL_LLERRORCONTROL_H #include "llerror.h" - +#include "boost/function.hpp" #include <string> class LLFixedBuffer; @@ -83,16 +83,38 @@ namespace LLError Control functions. */ - typedef void(*FatalFunction)(const std::string& message); + typedef boost::function<void(const std::string&)> FatalFunction; void crashAndLoop(const std::string& message); - // Default fatal funtion: access null pointer and loops forever + // Default fatal function: access null pointer and loops forever - void setFatalFunction(FatalFunction); + void setFatalFunction(const FatalFunction&); // The fatal function will be called when an message of LEVEL_ERROR // is logged. Note: supressing a LEVEL_ERROR message from being logged // (by, for example, setting a class level to LEVEL_NONE), will keep // the that message from causing the fatal funciton to be invoked. - + + FatalFunction getFatalFunction(); + // Retrieve the previously-set FatalFunction + + /// temporarily override the FatalFunction for the duration of a + /// particular scope, e.g. for unit tests + class OverrideFatalFunction + { + public: + OverrideFatalFunction(const FatalFunction& func): + mPrev(getFatalFunction()) + { + setFatalFunction(func); + } + ~OverrideFatalFunction() + { + setFatalFunction(mPrev); + } + + private: + FatalFunction mPrev; + }; + typedef std::string (*TimeFunction)(); std::string utcTime(); |