diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2018-12-10 17:14:31 -0500 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2018-12-10 17:14:31 -0500 |
commit | 9479d422d4b34e2ffd08017272412ab3bd1ae00e (patch) | |
tree | 0ce64f6d1c749662a3558a6b7f9e79f5f234cdcd /indra/llvfs/lldir_win32.cpp | |
parent | 73eadfa12a23ed5e2e47c208f18795061caff6f3 (diff) |
SL-10153: Use a degenerate singleton for PRELOG log file.
The previous build declared a static std::ofstream; but the code that
determines the pathname for the log file is called so early that static
objects have not yet been constructed. Declare a pointer instead, and
instantiate it on demand.
Diffstat (limited to 'indra/llvfs/lldir_win32.cpp')
-rw-r--r-- | indra/llvfs/lldir_win32.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/indra/llvfs/lldir_win32.cpp b/indra/llvfs/lldir_win32.cpp index 96bd779b5f..e97424c9a9 100644 --- a/indra/llvfs/lldir_win32.cpp +++ b/indra/llvfs/lldir_win32.cpp @@ -30,7 +30,6 @@ #include "lldir_win32.h" #include "llerror.h" -#include "llrand.h" // for gLindenLabRandomNumber #include "stringize.h" #include "llfile.h" #include <shlobj.h> @@ -47,8 +46,10 @@ DWORD GetDllVersion(LPCTSTR lpszDllName); namespace { // anonymous - enum class prst { INIT, OPEN, SKIP } state; - llofstream prelogf; + enum class prst { INIT, OPEN, SKIP } state = prst::INIT; + // This is called so early that we can't count on static objects being + // properly constructed yet, so declare a pointer instead of an instance. + std::ofstream* prelogf = nullptr; void prelog(const std::string& message) { @@ -64,18 +65,18 @@ namespace if (! prelog_name) // no PRELOG variable set, carry on return; - prelogf.open(prelog_name, std::ios_base::app); - if (! prelogf.is_open()) + prelogf = new std::ofstream(prelog_name, std::ios_base::app); + if (! (prelogf && prelogf->is_open())) // can't complain to anybody; how? return; // got the log file open, cool! state = prst::OPEN; - prelogf << "========================================================================" - << std::endl; + (*prelogf) << "========================================================================" + << std::endl; // fall through, don't break case prst::OPEN: - prelogf << message << std::endl; + (*prelogf) << message << std::endl; break; case prst::SKIP: |