X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fmisc.c;h=b71fee31934da47516917d3dbdb9e99aee3fdd49;hb=259128f543fa1c3c6f3bf8bff8309e815beedad6;hp=b1ea74e078f22d7e01dbf225d13692f7f74e3b0c;hpb=343ecd1bed93fa862903ff981ede342825f14401;p=rocksndiamonds.git diff --git a/src/libgame/misc.c b/src/libgame/misc.c index b1ea74e0..b71fee31 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -288,11 +288,22 @@ static void printf_log_prefix(int log_level, char *mode) printf_log_nonewline("[%s] ", log_token); } -static void Log(int log_level, char *mode, char *format, va_list ap) +static void vLog(int log_level, char *mode, char *format, va_list ap) { if (log_level < 0 || log_level > LOG_FATAL) return; + if (log_level == LOG_DEBUG) + { + if (!options.debug) + return; + + // if optional debug mode specified, limit debug output accordingly + if (options.debug_mode != NULL && + strstr(mode, options.debug_mode) == NULL) + return; + } + #if defined(PLATFORM_ANDROID) android_log_prio = (log_level == LOG_DEBUG ? ANDROID_LOG_DEBUG : log_level == LOG_INFO ? ANDROID_LOG_INFO : @@ -340,16 +351,8 @@ void Debug(char *mode, char *format, ...) { va_list ap; - if (!options.debug) - return; - - // if optional debug mode specified, limit debug output accordingly - if (options.debug_mode != NULL && - !strEqual(options.debug_mode, mode)) - return; - va_start(ap, format); - Log(LOG_DEBUG, mode, format, ap); + vLog(LOG_DEBUG, mode, format, ap); va_end(ap); } @@ -358,7 +361,7 @@ void Info(char *format, ...) va_list ap; va_start(ap, format); - Log(LOG_INFO, NULL, format, ap); + vLog(LOG_INFO, NULL, format, ap); va_end(ap); } @@ -367,7 +370,7 @@ void Warn(char *format, ...) va_list ap; va_start(ap, format); - Log(LOG_WARN, NULL, format, ap); + vLog(LOG_WARN, NULL, format, ap); va_end(ap); } @@ -2255,12 +2258,12 @@ static void dumpList(ListNode *node_first) while (node) { - printf("['%s' (%d)]\n", node->key, - ((struct ListNodeInfo *)node->content)->num_references); + Debug("internal:dumpList", "['%s' (%d)]", node->key, + ((struct ListNodeInfo *)node->content)->num_references); node = node->next; } - printf("[%d nodes]\n", getNumNodes(node_first)); + Debug("internal:dumpList", "[%d nodes]", getNumNodes(node_first)); } #endif @@ -3861,12 +3864,12 @@ void debug_print_timestamp(int counter_nr, char *message) counter[counter_nr][1] = counter[counter_nr][0]; if (message) - Error(ERR_DEBUG, "%s%s%s %.3f %s", - debug_print_timestamp_get_padding(counter_nr * indent_size), - message, - debug_print_timestamp_get_padding(padding_size - strlen(message)), - timestamp_interval / 1000, - unit); + Debug("time", "%s%s%s %.3f %s", + debug_print_timestamp_get_padding(counter_nr * indent_size), + message, + debug_print_timestamp_get_padding(padding_size - strlen(message)), + timestamp_interval / 1000, + unit); } #if 0