renamed function
[rocksndiamonds.git] / src / libgame / misc.c
index 8719e145160eb018f0520edc92a5ba8ba494f16f..b71fee31934da47516917d3dbdb9e99aee3fdd49 100644 (file)
@@ -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