- if (CMD_ARGC == 1)
- {
- unsigned new_level;
- COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], new_level);
- debug_level = MIN(new_level, LOG_LVL_DEBUG);
- }
- else if (CMD_ARGC > 1)
- return ERROR_COMMAND_SYNTAX_ERROR;
-
- if (debug_level >= LOG_LVL_DEBUG && server_use_pipes == 1)
- {
- /* if we are enabling debug info then we need to write to a log file
- * otherwise the pipe will get full and cause issues with gdb */
- FILE* file = fopen("openocd.log", "w");
- if (file)
- {
- log_output = file;
- LOG_WARNING("enabling log output as we are using pipes");
+ if (CMD_ARGC == 1) {
+ int new_level;
+ COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], new_level);
+ if ((new_level > LOG_LVL_DEBUG) || (new_level < LOG_LVL_SILENT)) {
+ LOG_ERROR("level must be between %d and %d", LOG_LVL_SILENT, LOG_LVL_DEBUG);
+ return ERROR_COMMAND_SYNTAX_ERROR;