From patchwork Wed Apr 28 07:41:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12228247 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46DEBC433ED for ; Wed, 28 Apr 2021 07:41:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 14ED961407 for ; Wed, 28 Apr 2021 07:41:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229643AbhD1Hmk (ORCPT ); Wed, 28 Apr 2021 03:42:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235862AbhD1Hmj (ORCPT ); Wed, 28 Apr 2021 03:42:39 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7784C061574 for ; Wed, 28 Apr 2021 00:41:53 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id c22so9343343edn.7 for ; Wed, 28 Apr 2021 00:41:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ony9CCi3ZuhktnoFXPiqJ16zopPIAgjwby4VYHLSEUA=; b=OtP8CvauwYskCsc47FreUlqAIhciU2kGzj+AG0fddFaE76lsEvG3cs5hc6UYGP3yPm IfLGVH+CnC3VMB5yN49Jm1aq2xtrz5ad4KitzqCLrBnKgDkpzohDQj2xWLr1IFlRFUrC CZg442iTZnBK4BhBQ9iH6kHu9Qf/KoUjHpn5C/rPPFmVF7mPkVgdU8kRfNvg81Y/HHz9 EDTpbn3uq4MGpnHx3hBp2aSckZiDADRXeYS2bEDgJUUS9pepFzLpdzyw2FDb1TISyeSB 4BCRQRQhta2hONV1fXIJcMfeKmcMleqzgBSHdLBsBIlsTlwtfIl5A6DluFo80DuAlOvL vPrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ony9CCi3ZuhktnoFXPiqJ16zopPIAgjwby4VYHLSEUA=; b=tvhL5cW78iT0oFd8GQ4kuu1BLf3lTSk6enXFBy2q2svQ34rehKoccJVNif48EIT4Dw sMuSGv//Nq4wdmenhvmzj9kPAgZncCWbAtSZgRm/3XG/yQ9RmLL6hiMx3qgI0G47cXxQ yuXYqvG+lIaUVsSb2ekBw6AtP+V4kVY4Ao1kaYMKtq6lsyLe9OaZMoDSaIJfEh2KWDoO +uMlDPOfjf0eURBRNRJlGUyzRhA5FtgxXrQ4pJHXGuA54i7Z9FArKnoahPi37tB+v2TB M5OkGiM/JRniH+g1RPh7gRcwHWgtlj6uWtUtdn4xWuZLgVGfjGrUOSvW8kywd142dyEA 9rnQ== X-Gm-Message-State: AOAM531DeQSVQaOU6NFc/zqsRM9l2RSUl9kYE0WxdojBnI/8cI0Sb4U6 BUgMh18Ru+rVTzyORjRcT2A= X-Google-Smtp-Source: ABdhPJzk5hoQKMGGN52Vy0VcDilnjhRSi8kW72TEP/LPAfDNsYubr3xqY1k9KeqzPsG0A8UuZkGXrw== X-Received: by 2002:aa7:c1c9:: with SMTP id d9mr9201862edp.155.1619595712586; Wed, 28 Apr 2021 00:41:52 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id k5sm4530504edk.46.2021.04.28.00.41.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:41:52 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 1/8] trace-cmd library: Use tep_vprint() for logs Date: Wed, 28 Apr 2021 10:41:42 +0300 Message-Id: <20210428074149.757163-2-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210428074149.757163-1-tz.stoyanov@gmail.com> References: <20210428074149.757163-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org The traceevent library funciton for printing logs is changed from tep_vwarning to tep_vprint. Signed-off-by: Tzvetomir Stoyanov (VMware) --- lib/trace-cmd/trace-util.c | 5 +++-- python/ctracecmd.i | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/trace-cmd/trace-util.c b/lib/trace-cmd/trace-util.c index 2d3bc741..4228b055 100644 --- a/lib/trace-cmd/trace-util.c +++ b/lib/trace-cmd/trace-util.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "trace-cmd-private.h" @@ -359,7 +360,7 @@ void __weak tracecmd_warning(const char *fmt, ...) va_list ap; va_start(ap, fmt); - tep_vwarning("libtracecmd", fmt, ap); + tep_vprint("libtracecmd", TEP_LOG_WARNING, fmt, ap); va_end(ap); } @@ -369,7 +370,7 @@ void __weak tracecmd_fatal(const char *fmt, ...) va_list ap; va_start(ap, fmt); - ret = tep_vwarning("libtracecmd", fmt, ap); + ret = tep_vprint("libtracecmd", TEP_LOG_CRITICAL, fmt, ap); va_end(ap); if (debug) { diff --git a/python/ctracecmd.i b/python/ctracecmd.i index e938c780..fa942215 100644 --- a/python/ctracecmd.i +++ b/python/ctracecmd.i @@ -63,7 +63,7 @@ void warning(const char *fmt, ...) return; va_start(ap, fmt); - tep_vwarning("tracecmd", fmt, ap); + tep_vprint("tracecmd", TEP_LOG_WARNING, fmt, ap); va_end(ap); } From patchwork Wed Apr 28 07:41:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12228249 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 271ACC433B4 for ; Wed, 28 Apr 2021 07:41:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8921613FA for ; Wed, 28 Apr 2021 07:41:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236805AbhD1Hmj (ORCPT ); Wed, 28 Apr 2021 03:42:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbhD1Hmj (ORCPT ); Wed, 28 Apr 2021 03:42:39 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E666C06138A for ; Wed, 28 Apr 2021 00:41:55 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id l4so93126496ejc.10 for ; Wed, 28 Apr 2021 00:41:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w3zcNpacLQP5lvV0GVbXqc8L88nrr0NpbUPzQQqJApM=; b=gyzeOJwalzpOsov+raeBIzaFF4BIf7SvsQ9NN8dwYvgJcVTeE+DsHMUcVKB41I+btI c4NFtKkWw9lhYaPourb0Vw2fSXX0UjyVg63ojTZZXiMF2W+8cvI1D0wmLix7u43uAoCY NI4BCDlFrnZvBOEJGGJPJtZNVBdgwFPbI5BehojGTamxaRXjm9p2NOEHajgW+1DS5f6B gb844Zor+pqenF/h1FSEK5bnJ4gqkH4cXfhSL1N/55/TvK2s6Z3RwodBpC/pQlSw2K/I HRYiI9IfGckIGul5s5A3naKAlWVMOMTKRcX/rdDIDMHh5By/tKsj7t84NTBpvjirc55g a6qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w3zcNpacLQP5lvV0GVbXqc8L88nrr0NpbUPzQQqJApM=; b=ZeSZu93/Kc5G8KdYiij5Hj9prQjdsEOiTR2gXG0sb62hhlJKb250GhtNF9xajlm1Ps GG5xcaZjOrOdGTYtc5zqSQGegNbaYqk5aCi9kybMPxAd0MpD7UeO7bAkxG5NAJt7NoBf huR+47eZDwX55I7Lef6tnWTc8wY2XdoFhvN9WHtyNLXfZ/OjRl6NBUVOQj/CB2pksvyO Ur9cOH2DZfHEvdtOnxgQFwIcHQKFlQcPpajKln0ouTsDr/qsGDd789fdn9fn9fzEBYi+ qifMcEsh30VF7zVwMcDET0UH1G1hT8lWnwbcXKWqLlui0AVqOosZ8BvA86u9jBYk77Z+ OhAg== X-Gm-Message-State: AOAM530q1ydLd500ItuZA4GWDjgYC0slDDt2guRv1DXdDaxlkEpnVFRJ cn4GqNdAO94pBEgexMe04/gisNqHMa2Lxg== X-Google-Smtp-Source: ABdhPJybotw/Gy6xYdie/92zsJq/czr2Nnu9nblb4or1GKbsKNd8zp/BLiMG9TuyzmhWWLU0WRw/Bw== X-Received: by 2002:a17:906:cec2:: with SMTP id si2mr28128474ejb.234.1619595713796; Wed, 28 Apr 2021 00:41:53 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id k5sm4530504edk.46.2021.04.28.00.41.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:41:53 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 2/8] trace-cmd library: Add tracecmd_info() log function Date: Wed, 28 Apr 2021 10:41:43 +0300 Message-Id: <20210428074149.757163-3-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210428074149.757163-1-tz.stoyanov@gmail.com> References: <20210428074149.757163-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org The pr_stat() function is removed from the traceevent library. This function was used by trace-cmd to print statistics. Introduce tracecmd_info() log function and replace pr_stat() with it in the trace-cmd library. However, pr_stat() is used also in the trace-cmd application. In order no to change the existing behaviour, add a static pr_stat() implementation for that usage. Signed-off-by: Tzvetomir Stoyanov (VMware) --- lib/trace-cmd/include/trace-cmd-local.h | 1 + lib/trace-cmd/trace-input.c | 2 +- lib/trace-cmd/trace-plugin.c | 2 +- lib/trace-cmd/trace-util.c | 10 ++++++++++ python/ctracecmd.i | 11 ----------- tracecmd/trace-cmd.c | 14 -------------- tracecmd/trace-record.c | 14 ++++++++++++++ 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/trace-cmd/include/trace-cmd-local.h b/lib/trace-cmd/include/trace-cmd-local.h index e8533b22..cd868f60 100644 --- a/lib/trace-cmd/include/trace-cmd-local.h +++ b/lib/trace-cmd/include/trace-cmd-local.h @@ -12,6 +12,7 @@ /* Can be overridden */ void tracecmd_warning(const char *fmt, ...); void tracecmd_fatal(const char *fmt, ...); +void tracecmd_info(const char *fmt, ...); /* trace.dat file format version */ #define FILE_VERSION 6 diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c index b17b36e0..733e1858 100644 --- a/lib/trace-cmd/trace-input.c +++ b/lib/trace-cmd/trace-input.c @@ -3280,7 +3280,7 @@ struct tracecmd_input *tracecmd_alloc_fd(int fd, int flags) version = read_string(handle); if (!version) goto failed_read; - pr_stat("version = %s\n", version); + tracecmd_info("version = %s\n", version); free(version); if (do_read_check(handle, buf, 1)) diff --git a/lib/trace-cmd/trace-plugin.c b/lib/trace-cmd/trace-plugin.c index ca7cadae..50c800c2 100644 --- a/lib/trace-cmd/trace-plugin.c +++ b/lib/trace-cmd/trace-plugin.c @@ -140,7 +140,7 @@ load_plugin(struct trace_plugin_context *trace, const char *path, list->name = plugin; *plugin_list = list; - pr_stat("registering plugin: %s", plugin); + tracecmd_info("registering plugin: %s", plugin); func(trace); return; diff --git a/lib/trace-cmd/trace-util.c b/lib/trace-cmd/trace-util.c index 4228b055..77259357 100644 --- a/lib/trace-cmd/trace-util.c +++ b/lib/trace-cmd/trace-util.c @@ -364,6 +364,16 @@ void __weak tracecmd_warning(const char *fmt, ...) va_end(ap); } +void tracecmd_info(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + tep_vprint("libtracecmd", TEP_LOG_INFO, fmt, ap); + va_end(ap); +} + + void __weak tracecmd_fatal(const char *fmt, ...) { int ret; diff --git a/python/ctracecmd.i b/python/ctracecmd.i index fa942215..229b54f3 100644 --- a/python/ctracecmd.i +++ b/python/ctracecmd.i @@ -44,17 +44,6 @@ static void py_supress_trace_output(void) skip_output = 1; } -void pr_stat(const char *fmt, ...) -{ - va_list ap; - - if (skip_output) - return; - va_start(ap, fmt); - __vpr_stat(fmt, ap); - va_end(ap); -} - void warning(const char *fmt, ...) { va_list ap; diff --git a/tracecmd/trace-cmd.c b/tracecmd/trace-cmd.c index 7376c5a5..60cd3ea1 100644 --- a/tracecmd/trace-cmd.c +++ b/tracecmd/trace-cmd.c @@ -35,20 +35,6 @@ void warning(const char *fmt, ...) fprintf(stderr, "\n"); } -void pr_stat(const char *fmt, ...) -{ - va_list ap; - - if (!show_status) - return; - - va_start(ap, fmt); - vprintf(fmt, ap); - va_end(ap); - - printf("\n"); -} - void *malloc_or_die(unsigned int size) { void *data; diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index fd03a605..8805b10e 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -2934,6 +2934,20 @@ static void test_event(struct event_list *event, const char *path, *save = event; } +static void pr_stat(const char *fmt, ...) +{ + va_list ap; + + if (!show_status) + return; + + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); + + printf("\n"); +} + static int expand_event_files(struct buffer_instance *instance, const char *file, struct event_list *old_event) From patchwork Wed Apr 28 07:41:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12228253 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CBB6C433ED for ; Wed, 28 Apr 2021 07:41:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 414BC613EF for ; Wed, 28 Apr 2021 07:41:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236461AbhD1Hmm (ORCPT ); Wed, 28 Apr 2021 03:42:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235862AbhD1Hml (ORCPT ); Wed, 28 Apr 2021 03:42:41 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35244C061574 for ; Wed, 28 Apr 2021 00:41:56 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id e7so72904809edu.10 for ; Wed, 28 Apr 2021 00:41:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wE8HdGmKuoca9J+8oh31F6smXR7h6RkL8vlLj40oEP0=; b=B9PJQHhO/An3WrATj5x9zsQ8wWJRzv7trjG1ki0KCfMDVFZO/czUdNC3ZE1a5FLad9 hl4siKKL/aOpY7kIDlhe1hacuVmZnNIr+rbPltZfgl+dkpDhL2KgdctPHdiXa/5ic7gT 2sqku7luaJXD5VQPLl9zU5qQ5iGcOFZbIMFztxiaU+V2QhZf/73Y5qs0VbLE2a76I+Xt n8veJKaYvuu0zVM61CUsamZjPwGlhd6JTvlsJybw+vlssqFsqqIzpKprjIEbvwxkl/Mt chXGVrr91LVEq4/TFtOOYnEMY7Z2FjjjwznuBQpOTqGnTU0+v5/tckz9KQqwiOoyxURT c8ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wE8HdGmKuoca9J+8oh31F6smXR7h6RkL8vlLj40oEP0=; b=dzwQiNdSS8WP3w5uEVPm3AIbWgGFL301lU/d1hZ6lGFNLgWnj7ewAU8t/wR+uuUBYl z1OoKSwk3gdcYqVD9xnsWaiw5yzJQqF5+QeXY/RmdIHnjtYzVzyOB6NDfZFfZkbxun7K EIq5qDUA0Zy+tlr+yDt7wtvktHQlUWeel/SmPi2rXIkGrQasTVacZUxlBKiZ5YYdcbYY iv5fRe7hKnASLSjGxIuK8hJIKcZ2UunDDYZzOstNVGTA6LPiB4qDTFYEiVKdw/HjHqGK 2djVrfdKzV90QGz6eTW6USEyE8/5bGZYgj1jiv86qg3wPJ234lRwlJfD8IdBZNA/ns3O dX0Q== X-Gm-Message-State: AOAM533lvqP4W1UBzx4PZZW0h1Ij2GTQilD6haXNuAORRIGVMi5jZusD D3u5/zayIMEtS44YK3U3nNymhg5CvIA1/w== X-Google-Smtp-Source: ABdhPJyqaUQa55ql03a70k+x44nZ8aNBtcvcIS65k9R6l6uy2KiXftbLsblN2LO/KnqJMEtr2IB+DA== X-Received: by 2002:aa7:cd8b:: with SMTP id x11mr9433753edv.87.1619595714963; Wed, 28 Apr 2021 00:41:54 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id k5sm4530504edk.46.2021.04.28.00.41.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:41:54 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 3/8] trace-cmd library: Add log levels Date: Wed, 28 Apr 2021 10:41:44 +0300 Message-Id: <20210428074149.757163-4-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210428074149.757163-1-tz.stoyanov@gmail.com> References: <20210428074149.757163-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Add levels to library logs and introduce a new API to set the desired log severity: tracecmd_set_loglevel() When a new trace-cmd library log level is set, propagate it to tracefs and traceevent libraries as well. Removed the "weak" definition of the library log functions. Setting the desired log level can be used to silence the library logs, instead of overwriting the log functions. Signed-off-by: Tzvetomir Stoyanov (VMware) --- include/trace-cmd/trace-cmd.h | 2 ++ lib/trace-cmd/include/trace-cmd-local.h | 1 - lib/trace-cmd/trace-util.c | 26 ++++++++++++++++++++++--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/include/trace-cmd/trace-cmd.h b/include/trace-cmd/trace-cmd.h index 162cd318..1cfdc4af 100644 --- a/include/trace-cmd/trace-cmd.h +++ b/include/trace-cmd/trace-cmd.h @@ -41,4 +41,6 @@ int tracecmd_buffer_instances(struct tracecmd_input *handle); const char *tracecmd_buffer_instance_name(struct tracecmd_input *handle, int indx); struct tracecmd_input *tracecmd_buffer_instance_handle(struct tracecmd_input *handle, int indx); +void tracecmd_set_loglevel(enum tep_loglevel level); + #endif /* _TRACE_CMD_H */ diff --git a/lib/trace-cmd/include/trace-cmd-local.h b/lib/trace-cmd/include/trace-cmd-local.h index cd868f60..76179148 100644 --- a/lib/trace-cmd/include/trace-cmd-local.h +++ b/lib/trace-cmd/include/trace-cmd-local.h @@ -9,7 +9,6 @@ #include #include "trace-cmd-private.h" -/* Can be overridden */ void tracecmd_warning(const char *fmt, ...); void tracecmd_fatal(const char *fmt, ...); void tracecmd_info(const char *fmt, ...); diff --git a/lib/trace-cmd/trace-util.c b/lib/trace-cmd/trace-util.c index 77259357..6f9da7c7 100644 --- a/lib/trace-cmd/trace-util.c +++ b/lib/trace-cmd/trace-util.c @@ -30,7 +30,7 @@ #define PROC_STACK_FILE "/proc/sys/kernel/stack_tracer_enabled" static bool debug; - +static int log_level = TEP_LOG_CRITICAL; static FILE *logfp; const static struct { @@ -355,10 +355,24 @@ trace_load_plugins(struct tep_handle *tep, int flags) return list; } -void __weak tracecmd_warning(const char *fmt, ...) +/** + * tracecmd_set_loglevel - set log level of the library + * @level: desired level of the library messages + */ +void tracecmd_set_loglevel(enum tep_loglevel level) +{ + log_level = level; + tracefs_set_loglevel(level); + tep_set_loglevel(level); +} + +void tracecmd_warning(const char *fmt, ...) { va_list ap; + if (log_level < TEP_LOG_WARNING) + return; + va_start(ap, fmt); tep_vprint("libtracecmd", TEP_LOG_WARNING, fmt, ap); va_end(ap); @@ -368,17 +382,23 @@ void tracecmd_info(const char *fmt, ...) { va_list ap; + if (log_level < TEP_LOG_INFO) + return; + va_start(ap, fmt); tep_vprint("libtracecmd", TEP_LOG_INFO, fmt, ap); va_end(ap); } -void __weak tracecmd_fatal(const char *fmt, ...) +void tracecmd_fatal(const char *fmt, ...) { int ret; va_list ap; + if (log_level < TEP_LOG_CRITICAL) + return; + va_start(ap, fmt); ret = tep_vprint("libtracecmd", TEP_LOG_CRITICAL, fmt, ap); va_end(ap); From patchwork Wed Apr 28 07:41:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12228251 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94B1BC433B4 for ; Wed, 28 Apr 2021 07:41:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 60B99613FA for ; Wed, 28 Apr 2021 07:41:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235862AbhD1Hmm (ORCPT ); Wed, 28 Apr 2021 03:42:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236816AbhD1Hml (ORCPT ); Wed, 28 Apr 2021 03:42:41 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 281C1C06138A for ; Wed, 28 Apr 2021 00:41:57 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id c22so9343502edn.7 for ; Wed, 28 Apr 2021 00:41:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CRwQl1RkWZDQSE4aQ6fUQgbS1AnPlATPnJ7XQuODs1Q=; b=QzJuFXAAcNpNrqVFugqIpGy7r2SDoUQ67IjSAhZIYS18R/ln4uDUjtm5pGvtyV3sFm +bmJylVPI3lim9oZ7x1FwRILuS6DN3w4+uj9woXTB3rlnOi3pZoZx2Jp0YpAty+Epvyj UuvmRwxxWJAfI64TDBtN0eVIS57VTF2LofRJUjqCSqnd5aHh0GZszAOrsNhXGPNR8WR+ 0BASaY7EBhNUt7hFUDQYSZRETdG5mkH0im0ArOrCQmzFUjgqtD7zt2YayDzckrRerZ7V bMfhD/dZLHkZwbDzFJ9kyDrGLKPi3VUh9EvguYqxdylWyIneY9c81hKQeBF4S/wszGn1 6HAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CRwQl1RkWZDQSE4aQ6fUQgbS1AnPlATPnJ7XQuODs1Q=; b=h2aCLs9aE27eRDcnZMGvFEmod82iEEZRdKlLzH7ySBL3bMxBW15HgzEYRgDCi5I/2h cw4bcwGqrWBK/L54wsWNf1atLiqrb+rSjHm2k/wuSwaqOdAXFsAeY3UVLT21uq66VL+x eIqDpNJ0n0gsnjNirRJagL6whj6nUZ/snn9JsbN3ygGOi5ZUEBXdnUJW/v7NTp3Mo3QQ mgD/TAsCSXqtmdokaabmOP9bfsN6jGQS6aXmuOjP5SZrRVp7wedq/cTkYY3tqza+xSfK o+TGUD5FOdiZq0wDHudF7EZcpugeguU3J365HXXp+fXgmPh/EwCPsYJAVW16rXzaTjaj aF2w== X-Gm-Message-State: AOAM532OFVpuQ2JeGuLyAahTkdcXb1jD5j1S0ri7OnibZpgd2kWsfy9H xMHSz2Ge+3A+6oJp3EK6GiQBZzbgmBHjtA== X-Google-Smtp-Source: ABdhPJxW3zyOZb3DGTqOAHyV4HCvMrDzxYhWZjZLxPLW0Cgi5NjT+CdQ5+ft7yQuhxgtevPn241vPQ== X-Received: by 2002:aa7:cdcc:: with SMTP id h12mr9352018edw.273.1619595715950; Wed, 28 Apr 2021 00:41:55 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id k5sm4530504edk.46.2021.04.28.00.41.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:41:55 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 4/8] trace-cmd library: Document the API for log levels Date: Wed, 28 Apr 2021 10:41:45 +0300 Message-Id: <20210428074149.757163-5-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210428074149.757163-1-tz.stoyanov@gmail.com> References: <20210428074149.757163-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Updated trace-cmd library man pages with description of the API for setting the library log levels: tracecmd_set_loglevel() Signed-off-by: Tzvetomir Stoyanov (VMware) --- Documentation/libtracecmd/libtracecmd-log.txt | 78 +++++++++++++++++++ Documentation/libtracecmd/libtracecmd.txt | 3 + 2 files changed, 81 insertions(+) create mode 100644 Documentation/libtracecmd/libtracecmd-log.txt diff --git a/Documentation/libtracecmd/libtracecmd-log.txt b/Documentation/libtracecmd/libtracecmd-log.txt new file mode 100644 index 00000000..de5c2776 --- /dev/null +++ b/Documentation/libtracecmd/libtracecmd-log.txt @@ -0,0 +1,78 @@ +libtracecmd(3) +============= + +NAME +---- +tracecmd_set_loglevel - Set log level of the library + +SYNOPSIS +-------- +[verse] +-- +*#include * + +int *tracecmd_set_loglevel*(enum tep_loglevel _level_); +-- + +DESCRIPTION +----------- +The _tracecmd_set_loglevel()_ function sets the level of the library logs that will be printed on +the console. See _libtraceevent(3)_ for detailed desciription of the log levels. Setting the log +level to specific value means that logs from the previous levels will be printed too. For example +_TEP_LOG_WARNING_ will print any logs with severity _TEP_LOG_WARNING_, _TEP_LOG_ERROR_ and +_TEP_LOG_CRITICAL_. The default log level is _TEP_LOG_CRITICAL_. When a new level is set, it is +also propagated to the libtracefs and libtraceevent. + +EXAMPLE +------- +[source,c] +-- +#include +... +tracecmd_set_loglevel(TEP_LOG_ALL); +... +/* call libtracecmd, libtracefs or libtraceevent APIs and observe any logs they produce */ +... +tracecmd_set_loglevel(TEP_LOG_CRITICAL); +-- + +FILES +----- +[verse] +-- +*trace-cmd.h* + Header file to include in order to have access to the library APIs. +*-ltracecmd* + Linker switch to add when building a program that uses the library. +-- + +SEE ALSO +-------- +_libtracefs(3)_, +_libtraceevent(3)_, +_trace-cmd(1)_ +_trace-cmd.dat(5)_ + +AUTHOR +------ +[verse] +-- +*Steven Rostedt* +*Tzvetomir Stoyanov* +-- +REPORTING BUGS +-------------- +Report bugs to + +LICENSE +------- +libtracecmd is Free Software licensed under the GNU LGPL 2.1 + +RESOURCES +--------- +https://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git/ + +COPYING +------- +Copyright \(C) 2021 VMware, Inc. Free use of this software is granted under +the terms of the GNU Public License (GPL). diff --git a/Documentation/libtracecmd/libtracecmd.txt b/Documentation/libtracecmd/libtracecmd.txt index adc9321c..dc528ce0 100644 --- a/Documentation/libtracecmd/libtracecmd.txt +++ b/Documentation/libtracecmd/libtracecmd.txt @@ -33,6 +33,9 @@ Read tracing instances from a trace file: Get traceing peer information from a trace file: unsigned long long *tracecmd_get_traceid*(struct tracecmd_input pass:[*]_handle_); int *tracecmd_get_guest_cpumap*(struct tracecmd_input pass:[*]_handle_, unsigned long long _trace_id_, const char pass:[*]pass:[*]_name_, int pass:[*]_vcpu_count_, const int pass:[*]pass:[*]_cpu_pid_); + +Control library logs: + int *tracecmd_set_loglevel*(enum tep_loglevel _level_); -- DESCRIPTION From patchwork Wed Apr 28 07:41:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12228255 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDB3BC433B4 for ; Wed, 28 Apr 2021 07:42:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA311613EF for ; Wed, 28 Apr 2021 07:42:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236953AbhD1Hmo (ORCPT ); Wed, 28 Apr 2021 03:42:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236888AbhD1Hmn (ORCPT ); Wed, 28 Apr 2021 03:42:43 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 486F9C061574 for ; Wed, 28 Apr 2021 00:41:58 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id g10so5042356edb.0 for ; Wed, 28 Apr 2021 00:41:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dyRpt8LR3emmeL6vzgGDgPExTCJRo6rFUvBT6aaQ3as=; b=Be6LF4TPFX/MKqvsMUtjrlYXJNGgaRMLvhtTIL7lSju8JJP2/2tYO5Q/865Z70KwkY Dq6jru8Mp9BFqLbJEYNIB44LnKPmbIxBljRrmuGCV9aiYe/5PH3FmrFMGIr8q5KJiwhX EV6usCkdAWIxkhJ7S5SkVEHSZ6xuzu5Axw215UqJKHYNebSPEs468Dny3QLGnqnbPq1/ HpVXg5vRzlz7Fmqjl24idUkD/Z/bsQXnApnDROSnsKlaODNOUrcr8hWC3v4YBgwKZ+E6 M3NbU/4Ay+ZaB9N6NJGRuDp46BEu6abveGL+yw4d7WdUxTjQ6y2MclcDQ5Rs/pri2Tyk FQOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dyRpt8LR3emmeL6vzgGDgPExTCJRo6rFUvBT6aaQ3as=; b=BLOJucMZjodhxOQ/sBKECf2kECr/XPEFMzIxJeFIZ9lTbZZCRc5qVATdvOBkkca0Gg rF9d6x1mrjahZ8AySH3a3EDnzxBRJvNb/PdxrjJ6cQORn03omXc22nTzkNKby52jZTZJ drUJJhbtwHJnRBp+XjOUArTtU6MwfrHhe+zbcnP9nvhwUDL4oY/Eq5IC3DIfUTQ2O8h1 c2GyTcBo3vlsEEs1m3ShNC+l8JrV4nazicNpMjeTAGetThQkMBigBLSKoBzikfwyfH9u 5e+DRFenFsm6dS0aLAoySW+VrQg4NcmpJP0mcKI5piw11dNWzX/I9aGoAmi21sfLs5vT tJAQ== X-Gm-Message-State: AOAM531ToQVi/pYPo/LF41OG4hVQaKDyzIOgjhAFLOfQwZYeAV57+Upd buxwIhZClrbnOlgAYKhmN/1oupmKSPTa3Q== X-Google-Smtp-Source: ABdhPJwOiTmIz7HvS6X68AIJRcHgIVgpIMmiod005DiFTCAaGeua9dypMSsyk1hb/jBPFFU12SoM9A== X-Received: by 2002:a05:6402:cb6:: with SMTP id cn22mr9287266edb.302.1619595716990; Wed, 28 Apr 2021 00:41:56 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id k5sm4530504edk.46.2021.04.28.00.41.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:41:56 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 5/8] trace-cmd library: Renamed tracecmd_fatal() to tracecmd_critical() Date: Wed, 28 Apr 2021 10:41:46 +0300 Message-Id: <20210428074149.757163-6-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210428074149.757163-1-tz.stoyanov@gmail.com> References: <20210428074149.757163-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org The trace-cmd library function for pritning critical logs is renamed from tracecmd_fatal() to tracecmd_critical() to be consistent with the names of the log levels. Signed-off-by: Tzvetomir Stoyanov (VMware) --- lib/trace-cmd/include/trace-cmd-local.h | 2 +- lib/trace-cmd/trace-input.c | 12 ++++++------ lib/trace-cmd/trace-util.c | 5 ++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/trace-cmd/include/trace-cmd-local.h b/lib/trace-cmd/include/trace-cmd-local.h index 76179148..7bf620d4 100644 --- a/lib/trace-cmd/include/trace-cmd-local.h +++ b/lib/trace-cmd/include/trace-cmd-local.h @@ -10,7 +10,7 @@ #include "trace-cmd-private.h" void tracecmd_warning(const char *fmt, ...); -void tracecmd_fatal(const char *fmt, ...); +void tracecmd_critical(const char *fmt, ...); void tracecmd_info(const char *fmt, ...); /* trace.dat file format version */ diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c index 733e1858..f13402f8 100644 --- a/lib/trace-cmd/trace-input.c +++ b/lib/trace-cmd/trace-input.c @@ -1104,7 +1104,7 @@ static void __free_page(struct tracecmd_input *handle, struct page *page) int index; if (!page->ref_count) { - tracecmd_fatal("Page ref count is zero!\n"); + tracecmd_critical("Page ref count is zero!\n"); return; } @@ -1165,7 +1165,7 @@ void tracecmd_free_record(struct tep_record *record) return; if (!record->ref_count) { - tracecmd_fatal("record ref count is zero!"); + tracecmd_critical("record ref count is zero!"); return; } @@ -1175,7 +1175,7 @@ void tracecmd_free_record(struct tep_record *record) return; if (record->locked) { - tracecmd_fatal("freeing record when it is locked!"); + tracecmd_critical("freeing record when it is locked!"); return; } @@ -1376,7 +1376,7 @@ static int get_page(struct tracecmd_input *handle, int cpu, if (offset & (handle->page_size - 1)) { errno = -EINVAL; - tracecmd_fatal("bad page offset %llx", offset); + tracecmd_critical("bad page offset %llx", offset); return -1; } @@ -1384,7 +1384,7 @@ static int get_page(struct tracecmd_input *handle, int cpu, offset > handle->cpu_data[cpu].file_offset + handle->cpu_data[cpu].file_size) { errno = -EINVAL; - tracecmd_fatal("bad page offset %llx", offset); + tracecmd_critical("bad page offset %llx", offset); return -1; } @@ -1950,7 +1950,7 @@ tracecmd_peek_data(struct tracecmd_input *handle, int cpu) record = handle->cpu_data[cpu].next; if (!record->data) { - tracecmd_fatal("Something freed the record"); + tracecmd_critical("Something freed the record"); return NULL; } diff --git a/lib/trace-cmd/trace-util.c b/lib/trace-cmd/trace-util.c index 6f9da7c7..25c1ee92 100644 --- a/lib/trace-cmd/trace-util.c +++ b/lib/trace-cmd/trace-util.c @@ -390,8 +390,7 @@ void tracecmd_info(const char *fmt, ...) va_end(ap); } - -void tracecmd_fatal(const char *fmt, ...) +void tracecmd_critical(const char *fmt, ...) { int ret; va_list ap; @@ -560,7 +559,7 @@ int tracecmd_count_cpus(void) fp = fopen("/proc/cpuinfo", "r"); if (!fp) { - tracecmd_fatal("Can not read cpuinfo"); + tracecmd_critical("Can not read cpuinfo"); return 0; } From patchwork Wed Apr 28 07:41:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12228257 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A065AC433ED for ; Wed, 28 Apr 2021 07:42:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66D6B613F3 for ; Wed, 28 Apr 2021 07:42:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236888AbhD1Hmo (ORCPT ); Wed, 28 Apr 2021 03:42:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236922AbhD1Hmo (ORCPT ); Wed, 28 Apr 2021 03:42:44 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F00DC06138A for ; Wed, 28 Apr 2021 00:41:59 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id i24so13402490edy.8 for ; Wed, 28 Apr 2021 00:41:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZmpITfbu5iSXz343gdLkGmlkGx2yNagBgVhYyKZBci8=; b=XuvPC0u7UlG+aR2tf3GSV09gQDmw6rCdbqvEsXN6TtgsdSbNeY20Jlx3b9pC33Wm+u awgHV4L6oWtfY2rmoCAEiMCWhorNel7KQXofgKq4TA8firg3dfeCjHJaQZ7lyutmZFIA s0+JEe8i/+cVQDKg5470J9fAy3tmLu3FsfhqkxVePHYt1+ttiulejPhPHSSFqVo1/Dcz xE8x+XFEWfO8pGCdnXgQ9lYXDWDAcq8brvEMusVyBvbJvgBN+tmccUmHNqcWAnZ7x+YT I8t9GgP6AdNnT2p2xajALdSBwS+SxdnYWujNgxfnMHLmZHf82G3tSGEg9IOi5T6Mna7l k0PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZmpITfbu5iSXz343gdLkGmlkGx2yNagBgVhYyKZBci8=; b=nqlSwdyTkWVbI4Z91gXhAX/AU+9Qvgyde5njLdlDryltVl9B78BPaFWtdrHHMB5GR8 ooG7rHQRRPyPYckUVgKRElt9FlY5pDE43FcmW5xxQjkgjcB/whCuYxaR14G7kEUmwx+M F2E/70z98e0pJ5RN34ATlYmtMH+Nx1G+D8vbsSjmFnKkcHRNLIgK90MKemmUk+/kWPeI 6clJq09X0SBsDCP7Ne9MeF3mWZWJ9X55t9O3im1QbmZXqh0z3Vrf9d01lG9AVvplYJNy lL5J5XS2JtBfef9fHN+cxITx1WjDWiFhKmC0b3pk9EaolFVBWZ7VwdwnIZBPoC6L7T2U zmtg== X-Gm-Message-State: AOAM531MZAu+hGCeKRZWuNB+pBnxSd6T0dVBuccbkuLH+FYLo9UjhMiI HF2xgTQQbgkbKwNFCQE7nioaakd2ms1f1g== X-Google-Smtp-Source: ABdhPJw3c18IrfRWs60l3qd1vSZPTrth127dml4PAUFOQJ6hhic6fxx+XOtSLzalLPs2xI1iDRRxrA== X-Received: by 2002:aa7:c9cf:: with SMTP id i15mr9556905edt.4.1619595718213; Wed, 28 Apr 2021 00:41:58 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id k5sm4530504edk.46.2021.04.28.00.41.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:41:57 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 6/8] trace-cmd library: Set debug log level in debug mode Date: Wed, 28 Apr 2021 10:41:47 +0300 Message-Id: <20210428074149.757163-7-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210428074149.757163-1-tz.stoyanov@gmail.com> References: <20210428074149.757163-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org When the library works in debug mode, set the log level to debug. Signed-off-by: Tzvetomir Stoyanov (VMware) --- lib/trace-cmd/trace-util.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/trace-cmd/trace-util.c b/lib/trace-cmd/trace-util.c index 25c1ee92..6a2b237e 100644 --- a/lib/trace-cmd/trace-util.c +++ b/lib/trace-cmd/trace-util.c @@ -93,6 +93,11 @@ const char *tracecmd_clock_id2str(enum tracecmd_clocks clock) void tracecmd_set_debug(bool set_debug) { debug = set_debug; + + if (set_debug) + tracecmd_set_loglevel(TEP_LOG_DEBUG); + else + tracecmd_set_loglevel(TEP_LOG_CRITICAL); } /** From patchwork Wed Apr 28 07:41:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12228259 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DD44C433B4 for ; Wed, 28 Apr 2021 07:42:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3CB93613EF for ; Wed, 28 Apr 2021 07:42:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236816AbhD1Hmq (ORCPT ); Wed, 28 Apr 2021 03:42:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236961AbhD1Hmq (ORCPT ); Wed, 28 Apr 2021 03:42:46 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C992C061574 for ; Wed, 28 Apr 2021 00:42:00 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id j28so8980949edy.9 for ; Wed, 28 Apr 2021 00:42:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SPOaWJsxBy9jiR33nKuBm9Gr1I5tVG2vBI5Vhsy4z9Q=; b=KjrVx9gddpSZLnWfItyKlj8L3CuaPQhK/c+6KOsWoJcrq561pKCAmV6/Om5krJ+IV2 aweKn0aF3H20tpQ5H4dnz7jPV+e4JKpYfhCn0ASl4PgAq054s2Td1mvwbILjBVOXtW7H 8MD5IlAo/hu32wU1hRQdYZPxnFLdXMTi+HFdVaXN+J7JYF/EWVAlxfesHrLBSdI8IqvF pYQmv8RSIwVfisZ3SWFvDVV/ibEGWOh7lGJFjlxsJVo4JUMyoXif10KRo7yMHmjHlfsq FDw0dBJhOWebcl/sZhZ40DIImi5tOqcKsX8Hm3Ya674GC81uY++mF0WujHZCUsCVmNb4 D3vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SPOaWJsxBy9jiR33nKuBm9Gr1I5tVG2vBI5Vhsy4z9Q=; b=JUW77ApP3kMl46Yt6sSeS41n3w5lK5jLx4jyayFeE/Ol4uU55fi8P4cf95ZuIeY3DS Eeh3PTXh7m5CXs/1o9HTONkdwhUo6G/rPjM96VRn9EAGOn6I68hdSakymvH6QClA99yU Z/Ag0/lsDT6aU0exwsGHF0F35KUdkv4wqEpDPFeLPE44StrW/pWs8lJ5745wLcU5/XRJ uNgw47IXs9ndsoKuGe2qAakWbTZKH3LZbvon2QcjMau3y6uctApUXpFGdjzlACUcda64 Q2P4qB1gPhi/1in/UE8uI5oyAKe8exfUEiX5Dj+ccQ8rsmI+jWmW7pKKqq0LmW3kAP6G VHzQ== X-Gm-Message-State: AOAM5302SnMzFnQjPD2PzpCwkX1wzJbf9uY2RpofrTTSlSGRIzB3pT01 ZPQlt3WD+B9sY4IW9M0OEnsOX2U80slubA== X-Google-Smtp-Source: ABdhPJwOsjqhfLMh7HDTR/FAOZwV3+fXS4SVxdcZEWJ+CWKNvBfepMBOFsEvF2BX+nko6TNC+8SKVQ== X-Received: by 2002:a50:fb82:: with SMTP id e2mr9476227edq.272.1619595719215; Wed, 28 Apr 2021 00:41:59 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id k5sm4530504edk.46.2021.04.28.00.41.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:41:58 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 7/8] trace-cmd report: Set the log level with -V and -q options Date: Wed, 28 Apr 2021 10:41:48 +0300 Message-Id: <20210428074149.757163-8-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210428074149.757163-1-tz.stoyanov@gmail.com> References: <20210428074149.757163-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org When "trace-cmd report -V" is specified, set the log level to INFO. When "trace-cmd report -q" is specified, set the log level to NONE. Signed-off-by: Tzvetomir Stoyanov (VMware) --- tracecmd/trace-read.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tracecmd/trace-read.c b/tracecmd/trace-read.c index d962b671..aad57dae 100644 --- a/tracecmd/trace-read.c +++ b/tracecmd/trace-read.c @@ -1679,9 +1679,11 @@ void trace_report (int argc, char **argv) break; case 'V': show_status = 1; + tracecmd_set_loglevel(TEP_LOG_INFO); break; case 'q': silence_warnings = 1; + tracecmd_set_loglevel(TEP_LOG_NONE); break; case OPT_cpu: parse_cpulist(optarg); From patchwork Wed Apr 28 07:41:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 12228261 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E672BC433B4 for ; Wed, 28 Apr 2021 07:42:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B137D61407 for ; Wed, 28 Apr 2021 07:42:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237010AbhD1Hmu (ORCPT ); Wed, 28 Apr 2021 03:42:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236343AbhD1Hmt (ORCPT ); Wed, 28 Apr 2021 03:42:49 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55493C06138A for ; Wed, 28 Apr 2021 00:42:01 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id n25so897712edr.5 for ; Wed, 28 Apr 2021 00:42:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MTz7XU6grsmUvJW3IYxouFKkQ7mInncv6WxuWL8XCig=; b=L9mmS+xYTMsGRnuSbHoEM3CsaOHGKbEJjbUCuULYJdzibo/wpCXcmhFgZrZFspEEP6 nyW9vERLHU1H0qPORiG+gEBeR0wcgWu2AIrE0/ASaxRf0cmlHG1bae942qv/H3d7s6fV mEK/Q17YnEIThexpmJpG0z+QRcYza1Hty5czGS392PKtuCUH1Z7uZBcV6vSabsBpXrcH fbcqWZf/s6jT2s6ALt8/4g+3xCF7TEcIYs+xQpP2P4HxI9PXJasucFqAfgxyHWwuavtf cNLb9NDJixfU9oc0nOrclKWBfe4+HdKz7cx6vCvkCvO5WRGAS8hbaYnFor/WHXNVQw47 UVbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MTz7XU6grsmUvJW3IYxouFKkQ7mInncv6WxuWL8XCig=; b=bpBLAHfWnLg1O9Dxo9ASZBC6Miqg0/oPbIJE3ClKtLHR+IM/HrOG3pAWYKtN/Dwsra W/5qzyFXqBvAUubUnDmA8QdaLds1ooX65yumqy9tHGR8EqUhOQrdofTKFKlwPi8BBqk/ h6yptLy8qZsVkvDEevfCs6wVb0zz6eWE1WOCA78xd7ae/7Em5tRJbyADiqqiGLa8g8nO mXA4UtVMwEGGQ1JlxEvZq71rjZHigfd6/BwCowfu8P31jgBQD0YE7IhAQ5AEWuv6aSxc bcQvYB6kOzLJzcD1OjMTkGzCdIyEOqLBMr+pWdSmVx/lpnaXwU2K+hENNxc7P0nMX9ML k56A== X-Gm-Message-State: AOAM533pT51EfQS0o3AfvAZVljcHJl6d+BvqYIsEnM/8MkPSbH4l5X1H sagpiemEY9Bu5ZShp2WadWxAodqS+W2WOw== X-Google-Smtp-Source: ABdhPJx39akE4CCizWdceL6iDeqBYBk8hCk3ybyUXvhn71bwcDs8OwrNWx0LuX+O2r9rZNoCbOs7hQ== X-Received: by 2002:aa7:c7d5:: with SMTP id o21mr9392726eds.166.1619595720157; Wed, 28 Apr 2021 00:42:00 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id k5sm4530504edk.46.2021.04.28.00.41.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:41:59 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 8/8] trace-cmd: Add new function to set log level Date: Wed, 28 Apr 2021 10:41:49 +0300 Message-Id: <20210428074149.757163-9-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210428074149.757163-1-tz.stoyanov@gmail.com> References: <20210428074149.757163-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Introduce a new trace-cmd internal function to set the application log level. trace_set_verbose() The log level can be set using string with log id or log name. Signed-off-by: Tzvetomir Stoyanov (VMware) --- tracecmd/include/trace-local.h | 2 ++ tracecmd/trace-cmd.c | 41 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/tracecmd/include/trace-local.h b/tracecmd/include/trace-local.h index 1218de12..cb929be4 100644 --- a/tracecmd/include/trace-local.h +++ b/tracecmd/include/trace-local.h @@ -36,6 +36,8 @@ void usage(char **argv); extern int silence_warnings; extern int show_status; +int trace_set_verbose(char *level); + struct pid_record_data { int pid; int brass[2]; diff --git a/tracecmd/trace-cmd.c b/tracecmd/trace-cmd.c index 60cd3ea1..4e4a73af 100644 --- a/tracecmd/trace-cmd.c +++ b/tracecmd/trace-cmd.c @@ -45,6 +45,47 @@ void *malloc_or_die(unsigned int size) return data; } +static struct trace_log_severity { + int id; + const char *name; +} log_severtity[] = { + { .id = TEP_LOG_NONE, .name = "none" }, + { .id = TEP_LOG_CRITICAL, .name = "crit" }, + { .id = TEP_LOG_ERROR, .name = "err" }, + { .id = TEP_LOG_WARNING, .name = "warn" }, + { .id = TEP_LOG_INFO, .name = "info" }, + { .id = TEP_LOG_DEBUG, .name = "debug" }, + { .id = TEP_LOG_ALL, .name = "all" }, +}; + +int trace_set_verbose(char *level) +{ + int id; + + if (!level) + return -1; + + if (isdigit(level[0])) { + id = atoi(level); + if (id >= TEP_LOG_NONE && id <= TEP_LOG_ALL) { + tracecmd_set_loglevel(id); + return 0; + } + } else { + int size = sizeof(log_severtity) / sizeof(log_severtity[0]); + int i; + + for (i = 0; i < size; i++) { + if (strlen(level) >= strlen(log_severtity[i].name) && + !strncmp(level, log_severtity[i].name, strlen(log_severtity[i].name))) { + tracecmd_set_loglevel(log_severtity[i].id); + return 0; + } + } + } + + return -1; +} /** * struct command