X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fmisc.c;h=b71fee31934da47516917d3dbdb9e99aee3fdd49;hb=259128f543fa1c3c6f3bf8bff8309e815beedad6;hp=8719e145160eb018f0520edc92a5ba8ba494f16f;hpb=4fc0827fea3bd1e340f4a3e580d83be1c8e2356a;p=rocksndiamonds.git diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 8719e145..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); } @@ -574,10 +577,15 @@ void SkipUntilDelayReached(unsigned int *counter_var, unsigned int delay, #if 0 #if DEBUG - printf("::: %d: %d ms", *loop_var, delay); if (skip_frames) - printf(" -> SKIP %d FRAME(S) [%d ms]", skip_frames, skip_frames * delay); - printf("\n"); + Debug("internal:SkipUntilDelayReached", + "%d: %d ms -> SKIP %d FRAME(S) [%d ms]", + *loop_var, delay, + skip_frames, skip_frames * delay); + else + Debug("internal:SkipUntilDelayReached", + "%d: %d ms", + *loop_var, delay); #endif #endif @@ -2250,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 @@ -3856,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