support OPENOCD_DEBUG_LEVEL environment setting
authorZachary T Welch <zw@superlucidity.net>
Mon, 23 Nov 2009 20:14:05 +0000 (12:14 -0800)
committerZachary T Welch <zw@superlucidity.net>
Wed, 25 Nov 2009 18:29:06 +0000 (10:29 -0800)
Detect the OPENOCD_DEBUG_LEVEL setting in log_init(), allowing the
very early startup phases to be debugged.

src/helper/log.c

index 27fa831..3067ecc 100644 (file)
@@ -346,6 +346,19 @@ void log_init(void)
        if (debug_level == -1)
                debug_level = LOG_LVL_INFO;
 
+       char *debug_env = getenv("OPENOCD_DEBUG_LEVEL");
+       if (NULL != debug_env)
+       {
+               int value;
+               int retval = parse_int(debug_env, &value);
+               if (ERROR_OK == retval &&
+                               debug_level >= LOG_LVL_SILENT &&
+                               debug_level <= LOG_LVL_DEBUG)
+               {
+                       debug_level = value;
+               }
+       }
+
        if (log_output == NULL)
                log_output = stderr;