diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2009-05-08 21:08:08 +0000 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2009-05-08 21:08:08 +0000 |
commit | 3800c0df910c83e987184d541b868168fc2b5bec (patch) | |
tree | 91bcf4e13972ae02b9d6500c1d14de7bb8d37dc4 /indra/llcommon/llerrorcontrol.h | |
parent | 5da967dc744f35d5270c7cb0b8b23b993ecda3e1 (diff) |
svn merge -r114679:114681 svn+ssh://svn.lindenlab.com/svn/linden/branches/event-system/event-system-7 svn+ssh://svn.lindenlab.com/svn/linden/branches/event-system/event-system-8
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(); |