summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2019-11-12 17:02:11 -0500
committerNat Goodspeed <nat@lindenlab.com>2020-03-25 19:06:13 -0400
commit7826683fa264add84ef7d87fae5f962d27471a19 (patch)
tree797d7b4b3f19e92da3b7b91b7b98d12a424c19d1 /indra
parent99d4ddc6687fff0fb93b16192c8f713766874bfe (diff)
DRTVWR-476: Back out 355d9db4a59f: unroll stderr redirection.
Diffstat (limited to 'indra')
-rw-r--r--indra/llcommon/llerror.cpp68
1 files changed, 30 insertions, 38 deletions
diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp
index 188b76bbae..ea0d06b93c 100644
--- a/indra/llcommon/llerror.cpp
+++ b/indra/llcommon/llerror.cpp
@@ -119,67 +119,59 @@ namespace {
{
public:
RecordToFile(const std::string& filename):
- mName(filename),
- mFile(LLFile::fopen(filename, "a"))
+ mName(filename)
{
+ mFile.open(filename.c_str(), std::ios_base::out | std::ios_base::app);
if (!mFile)
{
- LL_WARNS() << "Error setting log file to " << filename << LL_ENDL;
+ LL_INFOS() << "Error setting log file to " << filename << LL_ENDL;
}
else
{
-#if LL_DARWIN || LL_LINUX
- // We use a number of classic-C libraries, some of which write
- // log output to stderr. The trouble with that is that unless
- // you launch the viewer from a console, stderr output is
- // lost. Redirect STDERR_FILENO to write into this log file.
- // But first, save the original stream in case we want it later.
- mSavedStderr = ::dup(STDERR_FILENO);
- ::dup2(::fileno(mFile), STDERR_FILENO);
-#endif
+ if (!LLError::getAlwaysFlush())
+ {
+ mFile.sync_with_stdio(false);
+ }
}
}
~RecordToFile()
{
-#if LL_DARWIN || LL_LINUX
- // restore stderr to its original fileno so any subsequent output
- // to stderr goes to original stream
- ::dup2(mSavedStderr, STDERR_FILENO);
-#endif
mFile.close();
}
- virtual bool enabled() override
- {
+ virtual bool enabled() override
+ {
#ifdef LL_RELEASE_FOR_DOWNLOAD
- return 1;
+ return 1;
#else
- return LLError::getEnabledLogTypesMask() & 0x02;
+ return LLError::getEnabledLogTypesMask() & 0x02;
#endif
- }
-
- bool okay() const { return bool(mFile); }
+ }
+
+ bool okay() const { return mFile.good(); }
- std::string getFilename() const { return mName; }
+ std::string getFilename() const { return mName; }
- virtual void recordMessage(LLError::ELevel level,
- const std::string& message) override
- {
- fwrite(message.c_str(), sizeof(char), message.length(), mFile);
- if (LLError::getAlwaysFlush())
- {
- ::fflush(mFile);
- }
- }
+ virtual void recordMessage(LLError::ELevel level,
+ const std::string& message) override
+ {
+ if (LLError::getAlwaysFlush())
+ {
+ mFile << message << std::endl;
+ }
+ else
+ {
+ mFile << message << "\n";
+ }
+ }
private:
const std::string mName;
- LLUniqueFile mFile;
- int mSavedStderr{0};
+ llofstream mFile;
};
-
-
+
+
class RecordToStderr : public LLError::Recorder
{
public: