@ -267,7 +267,7 @@ Misc::Locked<std::ostream&> getLockedRawStderr()
}
// Redirect cout and cerr to the log file
void setupLogging ( const std : : string & logDir , const std : : string & appName , std : : ios_base : : openmode mod e)
void setupLogging ( const std : : string & logDir , std : : string_view appNam e)
{
# if defined(_WIN32) && defined(_DEBUG)
// Redirect cout and cerr to VS debug output when running in debug mode
@ -276,7 +276,7 @@ void setupLogging(const std::string& logDir, const std::string& appName, std::io
std : : cerr . rdbuf ( & sb ) ;
# else
const std : : string logName = Misc : : StringUtils : : lowerCase ( appName ) + " .log " ;
logfile . open ( boost : : filesystem : : path ( logDir ) / logName , mode ) ;
logfile . open ( boost : : filesystem : : path ( logDir ) / logName , std: : ios : : out ) ;
coutsb . open ( Debug : : Tee ( logfile , * rawStdout ) ) ;
cerrsb . open ( Debug : : Tee ( logfile , * rawStderr ) ) ;
@ -287,7 +287,7 @@ void setupLogging(const std::string& logDir, const std::string& appName, std::io
}
int wrapApplication ( int ( * innerApplication ) ( int argc , char * argv [ ] ) , int argc , char * argv [ ] ,
const std : : string & appName , bool autoSetupLogging )
std : : string_view appName )
{
# if defined _WIN32
( void ) Debug : : attachParentConsole ( ) ;
@ -301,27 +301,16 @@ int wrapApplication(int (*innerApplication)(int argc, char *argv[]), int argc, c
{
Files : : ConfigurationManager cfgMgr ;
if ( autoSetupLogging )
{
std : : ios_base : : openmode mode = std : : ios : : out ;
// If we are collecting a stack trace, append to existing log file
if ( argc = = 2 & & strcmp ( argv [ 1 ] , crash_switch ) = = 0 )
mode | = std : : ios : : app ;
setupLogging ( cfgMgr . getLogPath ( ) . string ( ) , appName , mode ) ;
}
if ( const auto env = std : : getenv ( " OPENMW_DISABLE_CRASH_CATCHER " ) ; env = = nullptr | | std : : atol ( env ) = = 0 )
{
# if defined(_WIN32)
const std : : string crashLogName = Misc : : StringUtils : : lowerCase ( appName ) + " -crash.dmp " ;
Crash : : CrashCatcher crashy ( argc , argv , ( cfgMgr. getLogP ath( ) / crashLogName ) . make_preferred ( ) . string ( ) ) ;
Crash : : CrashCatcher crashy ( argc , argv , ( boost : : filesystem : : temp_directory_path ( ) / crashLogName ) . make_preferred ( ) . string ( ) ) ;
# else
const std : : string crashLogName = Misc : : StringUtils : : lowerCase ( appName ) + " -crash.log " ;
// install the crash handler as soon as possible. note that the log path
// does not depend on config being read.
crashCatcherInstall ( argc , argv , ( cfgMgr. getLogP ath( ) / crashLogName ) . string ( ) ) ;
crashCatcherInstall ( argc , argv , ( boost : : filesystem : : temp_directory_path ( ) / crashLogName ) . string ( ) ) ;
# endif
ret = innerApplication ( argc , argv ) ;
}
@ -333,7 +322,7 @@ int wrapApplication(int (*innerApplication)(int argc, char *argv[]), int argc, c
# if (defined(__APPLE__) || defined(__linux) || defined(__unix) || defined(__posix))
if ( ! isatty ( fileno ( stdin ) ) )
# endif
SDL_ShowSimpleMessageBox ( 0 , ( appName + " : Fatal error " ) . c_str ( ) , e . what ( ) , nullptr ) ;
SDL_ShowSimpleMessageBox ( 0 , ( std: : string ( appName) + " : Fatal error " ) . c_str ( ) , e . what ( ) , nullptr ) ;
Log ( Debug : : Error ) < < " Error: " < < e . what ( ) ;