X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fhelper%2Flog.c;h=3067ecc56180fadcdbbc797c784cdecb0147eceb;hp=3799fb322b91cf00a9120d51c27ea64170edc682;hb=a3d81eed4d2aac51056f36d7c00ee639bb39c552;hpb=29772ec37293e7fbc6f11cc8a73b5d4d820707c7 diff --git a/src/helper/log.c b/src/helper/log.c index 3799fb322b..3067ecc561 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -336,25 +336,33 @@ static struct command_registration log_command_handlers[] = { int log_register_commands(struct command_context *cmd_ctx) { - start = timeval_ms(); - return register_commands(cmd_ctx, NULL, log_command_handlers); } -int log_init(struct command_context *cmd_ctx) +void log_init(void) { - /* set defaults for daemon configuration, if not set by cmdline or cfgfile */ + /* set defaults for daemon configuration, + * if not set by cmdline or cfgfile */ if (debug_level == -1) debug_level = LOG_LVL_INFO; - if (log_output == NULL) + char *debug_env = getenv("OPENOCD_DEBUG_LEVEL"); + if (NULL != debug_env) { - log_output = stderr; + 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; + } } - start = last_time = timeval_ms(); + if (log_output == NULL) + log_output = stderr; - return ERROR_OK; + start = last_time = timeval_ms(); } int set_log_output(struct command_context *cmd_ctx, FILE *output)