From patchwork Tue Dec 2 17:15:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 5421671 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A0362BEEBA for ; Tue, 2 Dec 2014 17:16:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D1FB22028D for ; Tue, 2 Dec 2014 17:16:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id F255E20266 for ; Tue, 2 Dec 2014 17:16:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7560E6F481; Tue, 2 Dec 2014 09:16:33 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com [209.85.212.175]) by gabe.freedesktop.org (Postfix) with ESMTP id 1405E6F481 for ; Tue, 2 Dec 2014 09:16:32 -0800 (PST) Received: by mail-wi0-f175.google.com with SMTP id l15so28832280wiw.8 for ; Tue, 02 Dec 2014 09:16:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=mPPxaTpS5KlUXXlO3t/YrpvbdNduvpnnHEjOloO7fSc=; b=iQctdq7ysKvEVlV3zSnheQkX95jIg7uZ2VSoAX7phUcICqRjCSBHT30eQHE/hwJqZV 9z7z1u/YClECcmFbJR6Jmu0n0tari8guWfTpkvTcCIwkMuIsjRuPfcUY1NySspQ9TKF+ o6VWxwAbbReCgMm5v1nqljKiGKkh5wIZaCKom+6pb4ArkF/vNqDQjwJ3qPFU+ypyvY1R TSJxeE7UTUlV5xhj0bufjigOkHvlCt6eQYed/DI4zQIjOtLq4dM1cakls3qmi2AdTXDx v7cl5Vdles4WzAXfUBo40GhOWAlIjd1WoyOFkuIaRsFVzS+KGOBbe/QCWl+vmi09HLyj CNog== X-Gm-Message-State: ALoCoQnbIrykQAEoFpGLngpKnZVG5v8urK46upPbbAteV79XZvIoIXpo5sXnlH/luKS/sbNUqYbv X-Received: by 10.180.103.229 with SMTP id fz5mr21008271wib.31.1417540547747; Tue, 02 Dec 2014 09:15:47 -0800 (PST) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id n3sm32725757wjz.21.2014.12.02.09.15.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Dec 2014 09:15:47 -0800 (PST) From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Tue, 2 Dec 2014 17:15:38 +0000 Message-Id: <1417540539-23069-4-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1417540539-23069-1-git-send-email-thomas.wood@intel.com> References: <1417540539-23069-1-git-send-email-thomas.wood@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 4/5] lib: add optional log domain filtering X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Thomas Wood --- lib/igt_core.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/igt_core.c b/lib/igt_core.c index 4f4cf96..d53fabb 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -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 \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) + igt_log_domain_filter = strdup(optarg); break; case OPT_LIST_SUBTESTS: if (!run_single_subtest) @@ -1463,9 +1467,15 @@ void igt_vlog(const char *domain, enum igt_log_level level, const char *format, if (igt_log_level > level) return; + if (igt_log_level > level) + return; + if (!domain) domain = command_str; + if (igt_log_domain_filter && strcmp(igt_log_domain_filter, domain)) + return; + if (level == IGT_LOG_WARN) { file = stderr; fflush(stdout);