Re: [hatari-devel] Recent Hatari change problems

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hi,

On 04/19/2018 01:43 PM, Thomas Huth wrote:
On 19.04.2018 00:08, Eero Tamminen wrote:
I though it best to change all options.c logging to respect log
levels, instead of logging being a flag for option parsing. See
attached patch.

Bad idea. That way, all those "debug" log messages would show up during
normal program start again (with log level == info) and we're back to
where we started. So no, please don't do this.

The main thing was to make it respect logging level.  That way
user can control the verbosity instead of it being hard-coded
like now.  What level should be used for each individual message
is another thing [1].

I started to think best would be just fixing log.c to work better.
Attached is patch for that, after which the Opt_Log() stuff can be
changed to using Log_Printf().


[1] I guess debug level is OK for most of the messages, but
couple of them are such that they need to be output by default:
-D/--debug toggle, --debug-except, --disasm options

(These are relevant only when using debugger, so it should
be fine even with you :-). VDI messages I mentioned earlier,
come from vdi.c not options.c, and I already changed that to
output info only if it needed to modify user requested screen
size.)


	- Eero
diff -r a455f205b508 src/debug/log.c
--- a/src/debug/log.c	Tue Apr 24 00:02:38 2018 +0300
+++ b/src/debug/log.c	Tue Apr 24 00:47:32 2018 +0300
@@ -160,6 +160,8 @@
 FILE *TraceFile = NULL;
 
 static FILE *hLogFile = NULL;
+
+/* local settings, to be able change them temporarily */
 static LOGTYPE TextLogLevel;
 static LOGTYPE AlertDlgLogLevel;
 
@@ -174,6 +176,17 @@
 	TextLogLevel = LOG_INFO;
 }
 
+/**
+ * Set local log levels from configuration values
+ */
+void Log_SetLevels(void)
+{
+	TextLogLevel = ConfigureParams.Log.nTextLogLevel;
+	AlertDlgLogLevel = ConfigureParams.Log.nAlertDlgLogLevel;
+
+	bCpuWriteLog = (TextLogLevel == LOG_DEBUG);
+}
+
 /*-----------------------------------------------------------------------*/
 /**
  * Initialize the logging and tracing functionality (open the log files etc.).
@@ -182,10 +195,7 @@
  */
 int Log_Init(void)
 {
-	TextLogLevel = ConfigureParams.Log.nTextLogLevel;
-	AlertDlgLogLevel = ConfigureParams.Log.nAlertDlgLogLevel;
-
-	bCpuWriteLog = (TextLogLevel == LOG_DEBUG);
+	Log_SetLevels();
 
 	hLogFile = File_Open(ConfigureParams.Log.sLogFileName, "w");
 	TraceFile = File_Open(ConfigureParams.Log.sTraceFileName, "w");
diff -r a455f205b508 src/debug/log.h
--- a/src/debug/log.h	Tue Apr 24 00:02:38 2018 +0300
+++ b/src/debug/log.h	Tue Apr 24 00:47:32 2018 +0300
@@ -69,6 +69,7 @@
 #endif
 
 extern void Log_Default(void);
+extern void Log_SetLevels(void);
 extern int Log_Init(void);
 extern int Log_SetAlertLevel(int level);
 extern void Log_UnInit(void);
diff -r a455f205b508 src/options.c
--- a/src/options.c	Tue Apr 24 00:02:38 2018 +0300
+++ b/src/options.c	Tue Apr 24 00:47:32 2018 +0300
@@ -2102,6 +2102,7 @@
 			{
 				return Opt_ShowError(OPT_LOGLEVEL, argv[i], "Unknown log level!");
 			}
+			Log_SetLevels();
 			break;
 
 		case OPT_ALERTLEVEL:
@@ -2111,6 +2112,7 @@
 			{
 				return Opt_ShowError(OPT_ALERTLEVEL, argv[i], "Unknown alert level!");
 			}
+			Log_SetLevels();
 			break;
 
 		case OPT_RUNVBLS:


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/