lib: add optional log domain filtering
authorThomas Wood <thomas.wood@intel.com>
Tue, 2 Dec 2014 11:37:26 +0000 (11:37 +0000)
committerThomas Wood <thomas.wood@intel.com>
Thu, 11 Dec 2014 17:57:03 +0000 (17:57 +0000)
v2: add an "application" filter for the default domain (used by
    applications)

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
docs/reference/intel-gpu-tools/igt_test_programs.xml
lib/igt_core.c

index 970ecb9..36ad1f3 100644 (file)
           </varlistentry>
 
           <varlistentry>
-            <term><option>--debug</option></term>
+            <term><option>--debug[=log-domain]</option></term>
             <listitem><para>
-                print extra debugging information when running tests
+                print extra debugging information when running tests and
+                optionaly only show the messages from the specified log domain
+                (use "application" to specifiy the default application domain)
             </para></listitem>
           </varlistentry>
 
index b247a03..e12b566 100644 (file)
@@ -228,6 +228,8 @@ enum {
  OPT_HELP = 'h'
 };
 
+static char* igt_log_domain_filter;
+
 __attribute__((format(printf, 1, 2)))
 static void kmsg(const char *format, ...)
 #define KERN_EMER      "<0>"
@@ -390,7 +392,7 @@ static void print_usage(const char *help_str, bool output_on_stderr)
        fprintf(f, "Usage: %s [OPTIONS]\n", command_str);
        fprintf(f, "  --list-subtests\n"
                   "  --run-subtest <pattern>\n"
-                  "  --debug\n"
+                  "  --debug[=log-domain]\n"
                   "  --help-description\n"
                   "  --help\n");
        if (help_str)
@@ -422,7 +424,7 @@ static int common_init(int argc, char **argv,
                {"list-subtests", 0, 0, OPT_LIST_SUBTESTS},
                {"run-subtest", 1, 0, OPT_RUN_SUBTEST},
                {"help-description", 0, 0, OPT_DESCRIPTION},
-               {"debug", 0, 0, OPT_DEBUG},
+               {"debug", optional_argument, 0, OPT_DEBUG},
                {"help", 0, 0, OPT_HELP},
                {0, 0, 0, 0}
        };
@@ -510,6 +512,8 @@ static int common_init(int argc, char **argv,
                switch(c) {
                case OPT_DEBUG:
                        igt_log_level = IGT_LOG_DEBUG;
+                       if (optarg && strlen(optarg) > 0)
+                               igt_log_domain_filter = strdup(optarg);
                        break;
                case OPT_LIST_SUBTESTS:
                        if (!run_single_subtest)
@@ -1476,6 +1480,15 @@ void igt_vlog(const char *domain, enum igt_log_level level, const char *format,
        if (igt_log_level > level)
                return;
 
+       if (igt_log_domain_filter) {
+               /* if null domain and filter is not "application", return */
+               if (!domain && strcmp(igt_log_domain_filter, "application"))
+                       return;
+               /* else if domain and filter do not match, return */
+               else if (domain && strcmp(igt_log_domain_filter, domain))
+                       return;
+       }
+
        if (level == IGT_LOG_WARN) {
                file = stderr;
                fflush(stdout);