mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
Fix logging fatal exceptions to cerr, and log them to openmw.log
This commit is contained in:
parent
4f742fd468
commit
54d8606b78
1 changed files with 14 additions and 8 deletions
|
@ -294,9 +294,19 @@ private:
|
|||
|
||||
int main(int argc, char**argv)
|
||||
{
|
||||
// Some objects used to redirect cout and cerr
|
||||
// Scope must be here, so this still works inside the catch block for logging exceptions
|
||||
std::streambuf* cout_rdbuf = std::cout.rdbuf ();
|
||||
std::streambuf* cerr_rdbuf = std::cerr.rdbuf ();
|
||||
|
||||
boost::iostreams::stream_buffer<Tee> coutsb;
|
||||
boost::iostreams::stream_buffer<Tee> cerrsb;
|
||||
|
||||
std::ostream oldcout(cout_rdbuf);
|
||||
std::ostream oldcerr(cerr_rdbuf);
|
||||
|
||||
boost::filesystem::ofstream logfile;
|
||||
|
||||
int ret = 0;
|
||||
try
|
||||
{
|
||||
|
@ -310,20 +320,16 @@ int main(int argc, char**argv)
|
|||
std::cerr.rdbuf (&sb);
|
||||
#else
|
||||
// Redirect cout and cerr to openmw.log
|
||||
boost::filesystem::ofstream logfile (boost::filesystem::path(
|
||||
cfgMgr.getLogPath() / "/openmw.log"));
|
||||
logfile.open (boost::filesystem::path(cfgMgr.getLogPath() / "/openmw.log"));
|
||||
|
||||
boost::iostreams::stream_buffer<Tee> coutsb;
|
||||
std::ostream oldcout(cout_rdbuf);
|
||||
coutsb.open (Tee(logfile, oldcout));
|
||||
std::cout.rdbuf (&coutsb);
|
||||
|
||||
boost::iostreams::stream_buffer<Tee> cerrsb;
|
||||
std::ostream oldcerr(cerr_rdbuf);
|
||||
cerrsb.open (Tee(logfile, oldcerr));
|
||||
|
||||
std::cout.rdbuf (&coutsb);
|
||||
std::cerr.rdbuf (&cerrsb);
|
||||
#endif
|
||||
|
||||
|
||||
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX || OGRE_PLATFORM == OGRE_PLATFORM_APPLE
|
||||
// Unix crash catcher
|
||||
if ((argc == 2 && strcmp(argv[1], "--cc-handle-crash") == 0) || !is_debugger_attached())
|
||||
|
|
Loading…
Reference in a new issue