--- hatari/src/debug/log.c 2019/04/09 08:56:47 1.1.1.7 +++ hatari/src/debug/log.c 2019/04/09 08:59:17 1.1.1.9 @@ -20,6 +20,7 @@ const char Log_fileid[] = "Hatari log.c #include #include #include +#include #include "main.h" #include "configuration.h" @@ -85,6 +86,7 @@ static flagname_t TraceFlags[] = { { TRACE_CPU_PAIRING , "cpu_pairing" } , { TRACE_CPU_DISASM , "cpu_disasm" } , { TRACE_CPU_EXCEPTION , "cpu_exception" } , + { TRACE_CPU_REGS , "cpu_regs" } , { TRACE_CPU_ALL , "cpu_all" } , { TRACE_INT , "int" } , @@ -146,6 +148,8 @@ static flagname_t TraceFlags[] = { { TRACE_SCSIDRV , "scsidrv" } , + { TRACE_MEM , "mem" } , + { TRACE_ALL , "all" } }; #endif /* ENABLE_TRACING */ @@ -155,6 +159,8 @@ Uint64 LogTraceFlags = TRACE_NONE; FILE *TraceFile = NULL; static FILE *hLogFile = NULL; + +/* local settings, to be able change them temporarily */ static LOGTYPE TextLogLevel; static LOGTYPE AlertDlgLogLevel; @@ -169,6 +175,15 @@ void Log_Default(void) TextLogLevel = LOG_INFO; } +/** + * Set local log levels from configuration values + */ +void Log_SetLevels(void) +{ + TextLogLevel = ConfigureParams.Log.nTextLogLevel; + AlertDlgLogLevel = ConfigureParams.Log.nAlertDlgLogLevel; +} + /*-----------------------------------------------------------------------*/ /** * Initialize the logging and tracing functionality (open the log files etc.). @@ -177,8 +192,7 @@ void Log_Default(void) */ int Log_Init(void) { - TextLogLevel = ConfigureParams.Log.nTextLogLevel; - AlertDlgLogLevel = ConfigureParams.Log.nAlertDlgLogLevel; + Log_SetLevels(); hLogFile = File_Open(ConfigureParams.Log.sLogFileName, "w"); TraceFile = File_Open(ConfigureParams.Log.sTraceFileName, "w"); @@ -212,6 +226,20 @@ void Log_UnInit(void) /*-----------------------------------------------------------------------*/ /** + * Print log prefix when needed + */ +static void Log_PrintPrefix(FILE *fp, LOGTYPE idx) +{ + static const char* prefix[] = LOG_NAMES; + + assert(idx >= 0 && idx < ARRAY_SIZE(prefix)); + if (prefix[idx]) + fprintf(fp, "%s: ", prefix[idx]); +} + + +/*-----------------------------------------------------------------------*/ +/** * Output string to log file */ void Log_Printf(LOGTYPE nType, const char *psFormat, ...) @@ -220,6 +248,7 @@ void Log_Printf(LOGTYPE nType, const cha if (hLogFile && nType <= TextLogLevel) { + Log_PrintPrefix(hLogFile, nType); va_start(argptr, psFormat); vfprintf(hLogFile, psFormat, argptr); va_end(argptr); @@ -241,6 +270,7 @@ void Log_AlertDlg(LOGTYPE nType, const c /* Output to log file: */ if (hLogFile && nType <= TextLogLevel) { + Log_PrintPrefix(hLogFile, nType); va_start(argptr, psFormat); vfprintf(hLogFile, psFormat, argptr); va_end(argptr); @@ -396,7 +426,7 @@ const char* Log_SetExceptionDebugMask (c Uint64 mask = EXCEPT_NONE; errstr = Log_ParseOptionFlags(FlagsStr, ExceptionFlags, ARRAY_SIZE(ExceptionFlags), &mask); - ConfigureParams.Log.nExceptionDebugMask = mask; + ConfigureParams.Debugger.nExceptionDebugMask = mask; return errstr; }