X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fmisc.c;h=7b9beacc51ff555ce81431a5da94817037b331bd;hb=6948b28f2469407be9f8439c7d7f74a40038636f;hp=24b6d248b219935773034bf1e9e14f899e4063bd;hpb=4cd59cef0737229da365e385a8762e681a5e471f;p=rocksndiamonds.git diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 24b6d248..7b9beacc 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -293,6 +293,26 @@ static void Log(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 && + !strEqual(options.debug_mode, mode)) + return; + } + +#if defined(PLATFORM_ANDROID) + android_log_prio = (log_level == LOG_DEBUG ? ANDROID_LOG_DEBUG : + log_level == LOG_INFO ? ANDROID_LOG_INFO : + log_level == LOG_WARN ? ANDROID_LOG_WARN : + log_level == LOG_ERROR ? ANDROID_LOG_ERROR : + log_level == LOG_FATAL ? ANDROID_LOG_FATAL : + ANDROID_LOG_UNKNOWN); +#endif + static boolean last_line_was_separator = FALSE; char *log_token = log_tokens[log_level]; @@ -331,11 +351,6 @@ void Debug(char *mode, char *format, ...) { va_list ap; - // 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); va_end(ap); @@ -562,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 @@ -2238,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 @@ -3844,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