diff --git a/include/dosbox.h b/include/dosbox.h index ac7b4f34..b4b109ed 100644 --- a/include/dosbox.h +++ b/include/dosbox.h @@ -60,6 +60,104 @@ void DOSBOX_Init(void); class Config; extern Config * control; +extern Bitu errorlevel; + +inline void LOG_MSG(char* message) +{ + + if(errorlevel>=0) S_Warn(message); +} + +template +inline void LOG_MSG(char* message,type1 arg1) +{ + + if(errorlevel>=0) S_Warn(message,arg1); +} + +template +inline void LOG_MSG(char* message,type1 arg1,type2 arg2) +{ + + if(errorlevel>=0) S_Warn(message,arg1,arg2); +} + +template +inline void LOG_MSG(char* message,type1 arg1,type2 arg2,type3 arg3) +{ + + if (errorlevel>=0)S_Warn(message,arg1,arg2,arg3); +} + +#if C_LOGGING +inline void LOG_DEBUG(char * message) +{ + + if(errorlevel>=2) S_Warn(message); +} + +template +inline void LOG_DEBUG(char * message, type type1) +{ + + if(errorlevel>=2) S_Warn(message,type1); +} + +template +inline void LOG_WARN(char * message, type type1) +{ + + if(errorlevel>=1) S_Warn(message,type1); +} + +inline void LOG_WARN(char* message) +{ + + if(errorlevel>=1) S_Warn(message); +} + +inline void LOG_ERROR(char * message) +{ + + if(errorlevel>=0) S_Warn(message); +} + +template +inline void LOG_ERROR(char * message, type type1) +{ + + if(errorlevel>=0) S_Warn(message,type1); +} + +template +inline void LOG_ERROR(char * message, type1 arg1,type2 arg2) +{ + + if(errorlevel>=0) S_Warn(message,arg1,arg2); +} + +template +inline void LOG_WARN(char * message, type1 arg1,type2 arg2) +{ + + if(errorlevel>=1) S_Warn(message,arg1,arg2); +} + +template +inline void LOG_DEBUG(char * message, type1 arg1,type2 arg2) +{ + + if(errorlevel>=2) S_Warn(message,arg1,arg2); +} + +#else +#define LOG_DEBUG +#define LOG_WARN +#define LOG_ERROR +#endif + + + #endif diff --git a/settings.h.cvs b/settings.h.cvs index b3933b34..3eea7705 100644 --- a/settings.h.cvs +++ b/settings.h.cvs @@ -48,16 +48,4 @@ #define DEBUG_DMA 0 /* DMA Debugging */ #define DEBUG_DOS 0 /* DOS Debugging */ -#define LOG_MSG S_Warn - -#if C_LOGGING -#define LOG_DEBUG S_Warn -#define LOG_WARN S_Warn -#define LOG_ERROR S_Warn -#else -#define LOG_DEBUG -#define LOG_WARN -#define LOG_ERROR -#endif - #endif diff --git a/src/dosbox.cpp b/src/dosbox.cpp index 4df80388..4a31477c 100644 --- a/src/dosbox.cpp +++ b/src/dosbox.cpp @@ -40,7 +40,7 @@ /* NEEDS A CLEANUP */ char dosbox_basedir[CROSS_LEN]; Config * control; - +Bitu errorlevel=1; //during startup display reason for Exits //The whole load of startups for all the subfunctions void MSG_Init(Section_prop *); @@ -132,7 +132,8 @@ void DOSBOX_RunMachine(void){ static void DOSBOX_RealInit(Section * sec) { Section_prop * section=static_cast(sec); /* Initialize some dosbox internals */ - LastTicks=GetTicks(); + errorlevel=section->Get_int("WARNINGS"); + LastTicks=GetTicks(); DOSBOX_SetLoop(&Normal_Loop); MSG_Init(section); } diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index 08f4e110..272f9f7f 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -499,8 +499,8 @@ int main(int argc, char* argv[]) { control->StartUp(); /* Shutdown everything */ } catch (char * error) { - LOG_ERROR("Exit to error %s",error); + LOG_ERROR("Exit to error: %s",error); } GFX_Stop(); return 0; -}; \ No newline at end of file +}; diff --git a/src/misc/support.cpp b/src/misc/support.cpp index c9771c65..349b151a 100644 --- a/src/misc/support.cpp +++ b/src/misc/support.cpp @@ -214,18 +214,21 @@ void S_Warn(char * format,...) { GFX_ShowMsg(buf); #endif } - +char buf[1024]; //global as else it doesn't always gets thrown right (linux/gcc2.95) void E_Exit(char * format,...) { - char buf[1024]; - +// char buf[1024]; //see above + if(errorlevel>=1){ + va_list msg; - strcpy(buf,"EXIT:"); va_start(msg,format); - vsprintf(buf+strlen(buf),format,msg); + vsprintf(buf,format,msg); va_end(msg); strcat(buf,"\n"); - printf(buf); + } else { + strcpy(buf,"an unsupported feature\n"); + } + throw(buf); -}; \ No newline at end of file +};