[pypy-svn] pypy ootype-virtualrefs: add support for multiple comma-separated categories in PYPYLOG
antocuni
commits-noreply at bitbucket.org
Fri Apr 8 15:52:47 CEST 2011
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: ootype-virtualrefs
Changeset: r43225:006e50c09d54
Date: 2011-04-08 15:52 +0200
http://bitbucket.org/pypy/pypy/changeset/006e50c09d54/
Log: add support for multiple comma-separated categories in PYPYLOG
diff --git a/pypy/translator/cli/src/debug.cs b/pypy/translator/cli/src/debug.cs
--- a/pypy/translator/cli/src/debug.cs
+++ b/pypy/translator/cli/src/debug.cs
@@ -1,5 +1,6 @@
using System;
using System.IO;
+using System.Collections.Generic;
using System.Diagnostics;
// this code is modeled after translator/c/src/debug.h
@@ -21,7 +22,7 @@
static int have_debug_prints = -1;
static bool debug_ready = false;
static bool debug_profile = false;
- static string debug_prefix = null;
+ static string[] active_categories = null;
public static void close_file()
{
@@ -29,6 +30,14 @@
debug_file.Close();
}
+ public static bool startswithoneof(string category, string[] active_categories)
+ {
+ foreach(string cat in active_categories)
+ if (category.StartsWith(cat))
+ return true;
+ return false;
+ }
+
public static bool HAVE_DEBUG_PRINTS()
{
if ((have_debug_prints & 1) != 0) {
@@ -48,7 +57,8 @@
have_debug_prints <<= 1;
if (!debug_profile) {
/* non-profiling version */
- if (debug_prefix == null || !category.StartsWith(debug_prefix)) {
+ if (active_categories == null ||
+ !startswithoneof(category, active_categories)) {
/* wrong section name, or no PYPYLOG at all, skip it */
return;
}
@@ -83,7 +93,8 @@
}
else {
/* PYPYLOG=prefix:filename --- conditional logging */
- debug_prefix = filename.Substring(0, colon);
+ string debug_prefix = filename.Substring(0, colon);
+ active_categories = debug_prefix.Split(',');
filename = filename.Substring(colon+1);
}
if (filename != "-")
More information about the Pypy-commit
mailing list