summaryrefslogtreecommitdiff
path: root/indra/llcommon/llerror.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/llerror.cpp')
-rw-r--r--indra/llcommon/llerror.cpp50
1 files changed, 42 insertions, 8 deletions
diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp
index 3d4deac673..5964993928 100644
--- a/indra/llcommon/llerror.cpp
+++ b/indra/llcommon/llerror.cpp
@@ -227,7 +227,7 @@ namespace
LOG_CLASS(LogControlFile);
public:
- static LogControlFile& fromDirectory(const std::string& dir);
+ static LogControlFile *fromDirectory(const std::string& dir);
virtual void loadFile();
@@ -237,7 +237,7 @@ namespace
{ }
};
- LogControlFile& LogControlFile::fromDirectory(const std::string& dir)
+ LogControlFile *LogControlFile::fromDirectory(const std::string& dir)
{
std::string dirBase = dir + "/";
// NB: We have no abstraction in llcommon for the "proper"
@@ -253,8 +253,7 @@ namespace
file = dirBase + "logcontrol.xml";
}
- return * new LogControlFile(file);
- // NB: This instance is never freed
+ return new LogControlFile(file);
}
void LogControlFile::loadFile()
@@ -298,8 +297,11 @@ namespace
static Globals& get();
// return the one instance of the globals
+ static void Globals::cleanup();
+
private:
CallSiteVector callSites;
+ static Globals *sGlobals;
Globals()
: messageStreamInUse(false)
@@ -307,6 +309,8 @@ namespace
};
+ Globals *Globals::sGlobals;
+
void Globals::addCallSite(LLError::CallSite& site)
{
callSites.push_back(&site);
@@ -332,8 +336,16 @@ namespace
is.
See C++ FAQ Lite, sections 10.12 through 10.14
*/
- static Globals* globals = new Globals;
- return *globals;
+ if (sGlobals == NULL) {
+ sGlobals = new Globals;
+ }
+
+ return *sGlobals;
+ }
+
+ void Globals::cleanup()
+ {
+ delete sGlobals;
}
}
@@ -361,6 +373,7 @@ namespace LLError
int shouldLogCallCounter;
static Settings& get();
+ static void cleanup();
static void reset();
static Settings* saveAndReset();
@@ -391,6 +404,16 @@ namespace LLError
return *p;
}
+ void Settings::cleanup()
+ {
+ Settings*& ptr = getPtr();
+ if (ptr)
+ {
+ delete ptr;
+ ptr = NULL;
+ }
+ }
+
void Settings::reset()
{
Globals::get().invalidateCallSites();
@@ -469,6 +492,8 @@ namespace
}
+ static LogControlFile *gLogControlFile;
+
void commonInit(const std::string& dir)
{
LLError::Settings::reset();
@@ -486,8 +511,8 @@ namespace
LLError::addRecorder(new RecordToWinDebug);
#endif
- LogControlFile& e = LogControlFile::fromDirectory(dir);
- e.addToEventTimer();
+ gLogControlFile = LogControlFile::fromDirectory(dir);
+ gLogControlFile->addToEventTimer();
}
}
@@ -511,6 +536,15 @@ namespace LLError
commonInit(dir);
}
+ void cleanupLogging(void)
+ {
+ delete gLogControlFile;
+ gLogControlFile = NULL;
+
+ Settings::cleanup();
+ Globals::cleanup();
+ }
+
void setPrintLocation(bool print)
{
Settings& s = Settings::get();