From patchwork Tue Dec 2 17:15:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 5421761 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 10432BEEA8 for ; Tue, 2 Dec 2014 17:23:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1DE4A202F0 for ; Tue, 2 Dec 2014 17:23:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0E0BD202EC for ; Tue, 2 Dec 2014 17:23:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7C05D6F500; Tue, 2 Dec 2014 09:23:23 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wg0-f51.google.com (mail-wg0-f51.google.com [74.125.82.51]) by gabe.freedesktop.org (Postfix) with ESMTP id F3D036F500 for ; Tue, 2 Dec 2014 09:23:22 -0800 (PST) Received: by mail-wg0-f51.google.com with SMTP id k14so17630698wgh.10 for ; Tue, 02 Dec 2014 09:23:22 -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=QuzWgcm07/+E5XCg1msgYYtN7T8IoOE7bYinHWKJFEw=; b=k5934fmPyRUxwiTiM9lhIXakaevcIxaakSP3VDpT3REZSwHB8qnoyJPMFL4jaoZBI3 JZNVYMb4vXFTSCYwq1Jw4bQuf09OJ346RVBzVMrqZKb/5J1zWyerjuq0jKhw4DbC9y/9 Ip2s7iKfPvuVEEPa55mDgQROdQ9p4Tjo59k0XkaXL6pNrhxIuKHv0xxszYSI5rLFNMDU EDfICQ3N1KrU7kl753dEOxTD2Q1Ua/t3LtK36m0WS/SEYO6M51SQYaEf5Bvjx59fGBdt PtV02DYhd4QH2vVa/GaRONg+aWJqfVLYhFbJjoZNDrsw7yKezN3mXzvtqgX1w7lOU6tL qr9g== X-Gm-Message-State: ALoCoQnj3WUihLH3IFkrtDdM95tIHXYcEprCkfN0O1bkJxiTgoD9lG4I+9b7ErSwFUOUfY9Ux6Xm X-Received: by 10.180.206.229 with SMTP id lr5mr16999704wic.74.1417540546189; Tue, 02 Dec 2014 09:15:46 -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.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Dec 2014 09:15:45 -0800 (PST) From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Tue, 2 Dec 2014 17:15:37 +0000 Message-Id: <1417540539-23069-3-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 3/5] lib: introduce log domains 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 Log domains can be used to identify the source of log messages, such as the test being run or the helper library. Signed-off-by: Thomas Wood --- lib/Makefile.am | 3 ++- lib/igt_core.c | 21 +++++++++++++++------ lib/igt_core.h | 18 +++++++++++------- lib/igt_kms.c | 2 +- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/lib/Makefile.am b/lib/Makefile.am index ab82302..b0aeef3 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -10,7 +10,8 @@ noinst_HEADERS = check-ndebug.h AM_CPPFLAGS = -I$(top_srcdir) AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) \ - -DIGT_DATADIR=\""$(abs_top_srcdir)/tests"\" + -DIGT_DATADIR=\""$(abs_top_srcdir)/tests"\" \ + -DIGT_LOG_DOMAIN=\""libintel_tools"\" LDADD = $(CAIRO_LIBS) diff --git a/lib/igt_core.c b/lib/igt_core.c index f7763b5..4f4cf96 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -1429,12 +1429,12 @@ void igt_skip_on_simulation(void) * are disabled. "none" completely disables all output and is not recommended * since crucial issues only reported at the IGT_LOG_WARN level are ignored. */ -void igt_log(enum igt_log_level level, const char *format, ...) +void igt_log(const char *domain, enum igt_log_level level, const char *format, ...) { va_list args; va_start(args, format); - igt_vlog(level, format, args) + igt_vlog(domain, level, format, args); va_end(args); } @@ -1451,8 +1451,10 @@ void igt_log(enum igt_log_level level, const char *format, ...) * If there is no need to wrap up a vararg list in the caller it is simpler to * just use igt_log(). */ -void igt_vlog(enum igt_log_level level, const char *format, va_list args) +void igt_vlog(const char *domain, enum igt_log_level level, const char *format, va_list args) { + FILE *file; + assert(format); if (list_subtests) @@ -1461,11 +1463,18 @@ void igt_vlog(enum igt_log_level level, const char *format, va_list args) if (igt_log_level > level) return; + if (!domain) + domain = command_str; + if (level == IGT_LOG_WARN) { + file = stderr; fflush(stdout); - vfprintf(stderr, format, args); - } else - vprintf(format, args); + } + else + file = stdout; + + fprintf(file, "(%s:%d) ", domain, getpid()); + vfprintf(file, format, args); } static void igt_alarm_handler(int signal) diff --git a/lib/igt_core.h b/lib/igt_core.h index a258348..5c5ee25 100644 --- a/lib/igt_core.h +++ b/lib/igt_core.h @@ -512,16 +512,20 @@ bool igt_run_in_simulation(void); void igt_skip_on_simulation(void); /* structured logging */ +#ifndef IGT_LOG_DOMAIN +#define IGT_LOG_DOMAIN (NULL) +#endif + enum igt_log_level { IGT_LOG_DEBUG, IGT_LOG_INFO, IGT_LOG_WARN, IGT_LOG_NONE, }; -__attribute__((format(printf, 2, 3))) -void igt_log(enum igt_log_level level, const char *format, ...); -__attribute__((format(printf, 2, 0))) -void igt_vlog(enum igt_log_level level, const char *format, va_list args); +__attribute__((format(printf, 3, 4))) +void igt_log(const char *domain, enum igt_log_level level, const char *format, ...); +__attribute__((format(printf, 3, 0))) +void igt_vlog(const char *domain, enum igt_log_level level, const char *format, va_list args); /** * igt_debug: @@ -529,7 +533,7 @@ void igt_vlog(enum igt_log_level level, const char *format, va_list args); * * Wrapper for igt_log() for message at the IGT_LOG_DEBUG level. */ -#define igt_debug(f...) igt_log(IGT_LOG_DEBUG, f) +#define igt_debug(f...) igt_log(IGT_LOG_DOMAIN, IGT_LOG_DEBUG, f) /** * igt_info: @@ -537,7 +541,7 @@ void igt_vlog(enum igt_log_level level, const char *format, va_list args); * * Wrapper for igt_log() for message at the IGT_LOG_INFO level. */ -#define igt_info(f...) igt_log(IGT_LOG_INFO, f) +#define igt_info(f...) igt_log(IGT_LOG_DOMAIN, IGT_LOG_INFO, f) /** * igt_warn: @@ -545,7 +549,7 @@ void igt_vlog(enum igt_log_level level, const char *format, va_list args); * * Wrapper for igt_log() for message at the IGT_LOG_WARN level. */ -#define igt_warn(f...) igt_log(IGT_LOG_WARN, f) +#define igt_warn(f...) igt_log(IGT_LOG_DOMAIN, IGT_LOG_WARN, f) extern enum igt_log_level igt_log_level; /** diff --git a/lib/igt_kms.c b/lib/igt_kms.c index eb8e085..0421ee0 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -740,7 +740,7 @@ igt_display_log(igt_display_t *display, const char *fmt, ...) igt_debug("display: "); for (i = 0; i < display->log_shift; i++) igt_debug("%s", LOG_SPACES); - igt_vlog(IGT_LOG_DEBUG, fmt, args); + igt_vlog(IGT_LOG_DOMAIN, IGT_LOG_DEBUG, fmt, args); va_end(args); }