aboutsummaryrefslogtreecommitdiff
path: root/src/helper/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/helper/log.c')
-rw-r--r--src/helper/log.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/helper/log.c b/src/helper/log.c
index 3112255..b05850d 100644
--- a/src/helper/log.c
+++ b/src/helper/log.c
@@ -40,7 +40,7 @@
#endif
#endif
-int debug_level = -1;
+int debug_level = LOG_LVL_INFO;
static FILE *log_output;
static struct log_callback *log_callbacks;
@@ -91,6 +91,14 @@ static void log_puts(enum log_levels level,
const char *string)
{
char *f;
+
+ if (!log_output) {
+ /* log_init() not called yet; print on stderr */
+ fputs(string, stderr);
+ fflush(stderr);
+ return;
+ }
+
if (level == LOG_LVL_OUTPUT) {
/* do not prepend any headers, just print out what we were given and return */
fputs(string, log_output);
@@ -277,9 +285,6 @@ void log_init(void)
{
/* set defaults for daemon configuration,
* if not set by cmdline or cfgfile */
- if (debug_level == -1)
- debug_level = LOG_LVL_INFO;
-
char *debug_env = getenv("OPENOCD_DEBUG_LEVEL");
if (NULL != debug_env) {
int value;