X-Git-Url: http://git.kpe.io/?p=ctsim.git;a=blobdiff_plain;f=libctsupport%2Fsyserror.cpp;h=4aca18565d242a2256c89c1600488e8c66e15a30;hp=623e6629d117a76bf8756b1ce855f662be8fcd20;hb=40ef0ef58e4d5617d7ddb7b1d145e8981b61215f;hpb=c70eb596eeeeda21f872065d9e11a67996394626 diff --git a/libctsupport/syserror.cpp b/libctsupport/syserror.cpp index 623e662..4aca185 100644 --- a/libctsupport/syserror.cpp +++ b/libctsupport/syserror.cpp @@ -1,8 +1,8 @@ /***************************************************************************** ** This is part of the CTSim program -** Copyright (C) 1983-2000 Kevin Rosenberg +** Copyright (c) 1983-2001 Kevin Rosenberg ** -** $Id: syserror.cpp,v 1.15 2001/01/13 03:51:35 kevin Exp $ +** $Id: syserror.cpp,v 1.24 2003/03/15 14:52:36 kevin Exp $ ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License (version 2) as @@ -26,6 +26,9 @@ #include #include "ct.h" +#ifdef HAVE_WXWINDOWS +#include "../src/ctsim.h" +#endif /* NAME * sys_error System error handler @@ -35,10 +38,9 @@ * int severity Severity of error * char *msg Error message * args Argument list, direct transfer to printf stack -* Can take 24 byte transfer */ -static int s_reportErrorLevel = ERR_WARNING; // Set error reporting level +static int s_reportErrorLevel = ERR_TRACE; // Set error reporting level void sys_error (int severity, const char *msg, ...) @@ -51,11 +53,22 @@ void sys_error (int severity, const char *msg, ...) sys_verror (strOutput, severity, msg, arg); #ifdef HAVE_WXWINDOWS - if (g_bRunningWXWindows) - *theApp->getLog() << strOutput.c_str(); + if (g_bRunningWXWindows) { + if (theApp) { + wxCommandEvent eventLog (wxEVT_COMMAND_MENU_SELECTED, MAINMENU_LOG_EVENT ); + wxString msg (strOutput.c_str()); + msg += "\n"; + eventLog.SetString( msg ); + wxPostEvent( theApp->getMainFrame(), eventLog ); // send log event, thread safe + } else { + wxMutexGuiEnter(); + wxLog::OnLog (wxLOG_Message, strOutput.c_str(), time(NULL)); + wxMutexGuiLeave(); + } + } else #endif - std::cout << strOutput; + std::cout << strOutput << "\n"; va_end(arg); } @@ -71,7 +84,9 @@ void sys_verror (std::string& strOutput, int severity, const char *msg, va_list std::ostringstream os; - s_nErrorCount++; + if (severity > ERR_TRACE) + s_nErrorCount++; + if (severity != ERR_FATAL) { if (s_nErrorCount > MAX_ERROR_COUNT) return; @@ -113,11 +128,11 @@ void sys_verror (std::string& strOutput, int severity, const char *msg, va_list strncpy (errStr, sizeof(errStr), "Error message not available on this platform."); #endif - os << errStr << "\n"; + os << errStr; strOutput = os.str(); if (severity == ERR_FATAL) { - std::cerr << strOutput; + std::cerr << strOutput << "\n"; throw std::runtime_error (strOutput); }