mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-17 10:21:11 +00:00
Merge pull request #1871 from akortunov/extended_logging
[Regression] Move cerr initialization out of 'try' block
This commit is contained in:
commit
f7715db25f
@ -5,9 +5,6 @@
|
|||||||
#include <QLocalSocket>
|
#include <QLocalSocket>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
|
||||||
#include <components/crashcatcher/crashcatcher.hpp>
|
|
||||||
|
|
||||||
#include <components/fallback/validate.hpp>
|
#include <components/fallback/validate.hpp>
|
||||||
|
|
||||||
#include <components/nifosg/nifloader.hpp>
|
#include <components/nifosg/nifloader.hpp>
|
||||||
@ -27,10 +24,6 @@ CS::Editor::Editor (int argc, char **argv)
|
|||||||
mLock(), mMerge (mDocumentManager),
|
mLock(), mMerge (mDocumentManager),
|
||||||
mIpcServerName ("org.openmw.OpenCS"), mServer(NULL), mClientSocket(NULL)
|
mIpcServerName ("org.openmw.OpenCS"), mServer(NULL), mClientSocket(NULL)
|
||||||
{
|
{
|
||||||
// install the crash handler as soon as possible. note that the log path
|
|
||||||
// does not depend on config being read.
|
|
||||||
crashCatcherInstall(argc, argv, (mCfgMgr.getLogPath() / "openmw-cs-crash.log").string());
|
|
||||||
|
|
||||||
std::pair<Files::PathContainer, std::vector<std::string> > config = readConfig();
|
std::pair<Files::PathContainer, std::vector<std::string> > config = readConfig();
|
||||||
|
|
||||||
setupDataFiles (config.first);
|
setupDataFiles (config.first);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <components/version/version.hpp>
|
#include <components/version/version.hpp>
|
||||||
#include <components/crashcatcher/crashcatcher.hpp>
|
|
||||||
#include <components/files/configurationmanager.hpp>
|
#include <components/files/configurationmanager.hpp>
|
||||||
#include <components/files/escape.hpp>
|
#include <components/files/escape.hpp>
|
||||||
#include <components/fallback/validate.hpp>
|
#include <components/fallback/validate.hpp>
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "debugging.hpp"
|
#include "debugging.hpp"
|
||||||
|
|
||||||
|
#include <components/crashcatcher/crashcatcher.hpp>
|
||||||
|
|
||||||
namespace Debug
|
namespace Debug
|
||||||
{
|
{
|
||||||
std::streamsize DebugOutputBase::write(const char *str, std::streamsize size)
|
std::streamsize DebugOutputBase::write(const char *str, std::streamsize size)
|
||||||
@ -55,10 +57,20 @@ int wrapApplication(int (*innerApplication)(int argc, char *argv[]), int argc, c
|
|||||||
std::streambuf* cout_rdbuf = std::cout.rdbuf ();
|
std::streambuf* cout_rdbuf = std::cout.rdbuf ();
|
||||||
std::streambuf* cerr_rdbuf = std::cerr.rdbuf ();
|
std::streambuf* cerr_rdbuf = std::cerr.rdbuf ();
|
||||||
|
|
||||||
|
#if !(defined(_WIN32) && defined(_DEBUG))
|
||||||
|
boost::iostreams::stream_buffer<Debug::Tee> coutsb;
|
||||||
|
boost::iostreams::stream_buffer<Debug::Tee> cerrsb;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const std::string logName = Misc::StringUtils::lowerCase(appName) + ".log";
|
||||||
|
const std::string crashLogName = Misc::StringUtils::lowerCase(appName) + "-crash.log";
|
||||||
|
boost::filesystem::ofstream logfile;
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Files::ConfigurationManager cfgMgr;
|
Files::ConfigurationManager cfgMgr;
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(_DEBUG)
|
#if defined(_WIN32) && defined(_DEBUG)
|
||||||
// Redirect cout and cerr to VS debug output when running in debug mode
|
// Redirect cout and cerr to VS debug output when running in debug mode
|
||||||
boost::iostreams::stream_buffer<Debug::DebugOutput> sb;
|
boost::iostreams::stream_buffer<Debug::DebugOutput> sb;
|
||||||
@ -67,12 +79,8 @@ int wrapApplication(int (*innerApplication)(int argc, char *argv[]), int argc, c
|
|||||||
std::cerr.rdbuf (&sb);
|
std::cerr.rdbuf (&sb);
|
||||||
#else
|
#else
|
||||||
// Redirect cout and cerr to the log file
|
// Redirect cout and cerr to the log file
|
||||||
const std::string logName = Misc::StringUtils::lowerCase(appName) + ".log";
|
|
||||||
boost::filesystem::ofstream logfile;
|
|
||||||
logfile.open (boost::filesystem::path(cfgMgr.getLogPath() / logName));
|
logfile.open (boost::filesystem::path(cfgMgr.getLogPath() / logName));
|
||||||
|
|
||||||
boost::iostreams::stream_buffer<Debug::Tee> coutsb;
|
|
||||||
boost::iostreams::stream_buffer<Debug::Tee> cerrsb;
|
|
||||||
std::ostream oldcout(cout_rdbuf);
|
std::ostream oldcout(cout_rdbuf);
|
||||||
std::ostream oldcerr(cerr_rdbuf);
|
std::ostream oldcerr(cerr_rdbuf);
|
||||||
coutsb.open (Debug::Tee(logfile, oldcout));
|
coutsb.open (Debug::Tee(logfile, oldcout));
|
||||||
@ -81,6 +89,11 @@ int wrapApplication(int (*innerApplication)(int argc, char *argv[]), int argc, c
|
|||||||
std::cout.rdbuf (&coutsb);
|
std::cout.rdbuf (&coutsb);
|
||||||
std::cerr.rdbuf (&cerrsb);
|
std::cerr.rdbuf (&cerrsb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// install the crash handler as soon as possible. note that the log path
|
||||||
|
// does not depend on config being read.
|
||||||
|
crashCatcherInstall(argc, argv, (cfgMgr.getLogPath() / crashLogName).string());
|
||||||
|
|
||||||
ret = innerApplication(argc, argv);
|
ret = innerApplication(argc, argv);
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
@ -90,7 +103,7 @@ int wrapApplication(int (*innerApplication)(int argc, char *argv[]), int argc, c
|
|||||||
#endif
|
#endif
|
||||||
SDL_ShowSimpleMessageBox(0, (appName + ": Fatal error").c_str(), e.what(), NULL);
|
SDL_ShowSimpleMessageBox(0, (appName + ": Fatal error").c_str(), e.what(), NULL);
|
||||||
|
|
||||||
Log(Debug::Error) << "ERROR: " << e.what();
|
Log(Debug::Error) << "Error: " << e.what();
|
||||||
|
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user