From patchwork Thu Mar 13 16:38:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 3827191 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 352E19F2BB for ; Thu, 13 Mar 2014 16:39:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 52E3E201C0 for ; Thu, 13 Mar 2014 16:39:08 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7720920166 for ; Thu, 13 Mar 2014 16:39:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 123A2FB315; Thu, 13 Mar 2014 09:39:06 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-ee0-f44.google.com (mail-ee0-f44.google.com [74.125.83.44]) by gabe.freedesktop.org (Postfix) with ESMTP id 2ECD0FB305 for ; Thu, 13 Mar 2014 09:39:01 -0700 (PDT) Received: by mail-ee0-f44.google.com with SMTP id e49so528677eek.3 for ; Thu, 13 Mar 2014 09:38:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rgZeLIQg0E7GXVKCoQrWo+xXDZboU/xKVur1pBy6OYU=; b=JDkFTPWE06eGmLG4N6KXFsNxaR6QRssh44Az801YmbyipQqty8T5lEIHDl7aFSQ8zM PL9pKB7IFXR6Q2pyTTy2I926EJFAPd/YFJYjU9YimTife7V/hJKWRHjQ8/D77CVUnRbn ctMEm9HHM/ms/H/VQafkYmJYmRk7DOFKMgdcM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rgZeLIQg0E7GXVKCoQrWo+xXDZboU/xKVur1pBy6OYU=; b=lEASkKox2YFEK1wKH1T3HW0Xt2zGqUeu9malAU58T46kfYHSzbj1o5FWUFDGwrdFzs BXrK2plhAtuH7m7tOqpk7aSQ4ZLWtkZv1Rgg2/dbaCgMZx3WpJpQ7f0k1d0QZWU9fn6p 04A/K/QRBiljnt4Ny+U4GO+nk7hnnn5+EozhYep37e9qtLy3cz3gTWYKJQoMch2tJirp 4wZgLTaDpsTW5KY4d8lqMyeb+chEbHQI/+rrf5kS0iDKXn9nJAVt71mZ9K1XQ+k3asrT OuxW232WPNTcdZ6VYqDKORiNv47DvCmoSRMZhbpUKukQNhLUW8lBF9irLb8lQ5YYPoLC nPDQ== X-Gm-Message-State: ALoCoQlszcVF+W52Xsk3cbLlcFSBi6b8EAgrlE0jsOU0nuroUumaYZy1zLn3otMrjbUKm4C7cL+J X-Received: by 10.15.73.134 with SMTP id h6mr3283584eey.15.1394728739080; Thu, 13 Mar 2014 09:38:59 -0700 (PDT) Received: from aaron.ffwll.local (84-73-67-144.dclient.hispeed.ch. [84.73.67.144]) by mx.google.com with ESMTPSA id 48sm9982430eee.2.2014.03.13.09.38.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Mar 2014 09:38:58 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Date: Thu, 13 Mar 2014 17:38:46 +0100 Message-Id: <1394728726-8718-2-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.8.4.rc3 In-Reply-To: <1394728726-8718-1-git-send-email-daniel.vetter@ffwll.ch> References: <1394728726-8718-1-git-send-email-daniel.vetter@ffwll.ch> Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 2/2] lib: add igt_vlog to print varargs X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, 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 ... and put it to immediate use in igt_display_log. To make this all add up also drop the return value of igt_display_log, no one really cared anyway. Aside: I've noticed that every time another subtest runs (at least with kms_pipe_crc_basic) the log indent level moves one up ... Signed-off-by: Daniel Vetter --- lib/igt_core.c | 27 +++++++++++++++++++++++++++ lib/igt_core.h | 1 + lib/igt_kms.c | 15 +++++---------- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/lib/igt_core.c b/lib/igt_core.c index 13259b611c23..ff4711785654 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -1074,3 +1074,30 @@ void igt_log(enum igt_log_level level, const char *format, ...) vprintf(format, args); va_end(args); } + +/** + * igt_vlog: + * @level: #igt_log_level + * @format: format string + * @args: variable arguments lists + * + * This is the generic logging helper function using an explicit varargs + * structure and hence useful to implement domain-specific logging + * functions. + * + * 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) +{ + assert(format); + + if (igt_log_level > level) + return; + + if (level == IGT_LOG_WARN) { + fflush(stdout); + vfprintf(stderr, format, args); + } else + vprintf(format, args); +} diff --git a/lib/igt_core.h b/lib/igt_core.h index 0e3d7be00d1e..5c9065a5f1fb 100644 --- a/lib/igt_core.h +++ b/lib/igt_core.h @@ -389,6 +389,7 @@ enum igt_log_level { }; __attribute__((format(printf, 2, 3))) void igt_log(enum igt_log_level level, const char *format, ...); +void igt_vlog(enum igt_log_level level, const char *format, va_list args); /** * igt_debug: diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 2c0f89d8f0cc..d5d9e0228408 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -817,23 +817,18 @@ const char *plane_name(enum igt_plane p) } while (0) #define LOG(d, fmt, ...) igt_display_log(d, fmt, ## __VA_ARGS__) -static int __attribute__((format(printf, 2, 3))) +static void __attribute__((format(printf, 2, 3))) igt_display_log(igt_display_t *display, const char *fmt, ...) { va_list args; - int n, i; - - if (igt_log_level > IGT_LOG_DEBUG) - return 0; + int i; va_start(args, fmt); - n = printf("display: "); + igt_debug("display: "); for (i = 0; i < display->log_shift; i++) - n += printf("%s", LOG_SPACES); - n += vprintf(fmt, args); + igt_debug("%s", LOG_SPACES); + igt_vlog(IGT_LOG_DEBUG, fmt, args); va_end(args); - - return n; } static void igt_display_log_shift(igt_display_t *display, int shift)