From patchwork Mon May 17 13:40:00 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: 12261991 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.8 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 942AEC433ED for ; Mon, 17 May 2021 13:40:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6A457611BF for ; Mon, 17 May 2021 13:40:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237416AbhEQNl0 (ORCPT ); Mon, 17 May 2021 09:41:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237414AbhEQNlZ (ORCPT ); Mon, 17 May 2021 09:41:25 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6134EC061573 for ; Mon, 17 May 2021 06:40:09 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id k10so9261097ejj.8 for ; Mon, 17 May 2021 06:40:09 -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=SudxD4UZxhW/p8ZhQet0h3YmNrxCM+8a0ySSyKYnMQE=; b=MfNW+d9tia7wYfbH6ilEpFLjtUH+0jpsOguwvKtaEINQp2FuEDc6CRzkwUB4K6ksRa gPCiKtnWOHLDYQ/tk6WkWPecGpdSft2Fc10SgxFVbj4ITx8UKdS9Mg8dIdL6woCGIGBQ AJ6e5LnLfS9iOiRVxf2d0dgZ+iHpPD/+mtYGQF+pC0B3Bb+a/6ltfufRbrnvcaSPJx8D MXJMMfLJ6PIWjJh/7KjX16ZUy0lyiCpWBMs4Zm4WMH1hBwUOXjZz3OhXrCjlS/WB84XX qwPZmkNbT/rn+qcslNbMjxxZMNfCzUqGGSaggExQKBrQ23xIqsM6blLzxhRPn7uSbSzC +Liw== 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=SudxD4UZxhW/p8ZhQet0h3YmNrxCM+8a0ySSyKYnMQE=; b=VDAwgKeeq2Bzpe5/vhNa+52ClNZV/YsViG6iom16xroS7GWUidUtCQamgzLGYuqagT mtbE6vVLmb8+0TattVGw00brINtNeV8Q0iReHDF15LEEsLwYbDn1hvye5DzB2iHkn4R+ GNqDJ+7UIE6TCky+xeLrBekHSl5xF6fU7pBocKU333n7yXx7Yf6+MTz1trj1AX6S4SCf GtPR4OkRYXQCL4eoe3DxaCa/Q5jh3FNug47JP3Xc3igYoczMxj+GtRJB52ZmnxyRXK6T GLM04NCaPvFqB4+pJLS7T4N5bXZjl163ICFqp0oJCLKSywp7ScFeVZhPjhQ/rFcUqZiC dggg== X-Gm-Message-State: AOAM531D9O7ZpwZmOx1vE403YiHWODGtlqsiCsQvBIz8HdS2A9DvS4lM 7joYtsiuNK5z1ouVApi4wBwEsXzQeglgLg== X-Google-Smtp-Source: ABdhPJz6+zWSFKGU0Ajw9icS1D9KEiIOxpdS2lbIGcIYQP2i/rJd3CSJMZ6nupPJl/j9DSdfCimg8w== X-Received: by 2002:a17:906:1ed1:: with SMTP id m17mr63636853ejj.208.1621258808194; Mon, 17 May 2021 06:40:08 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id r25sm10961799edv.78.2021.05.17.06.40.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 06:40:07 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 1/6] trace-cmd library: Add log levels Date: Mon, 17 May 2021 16:40:00 +0300 Message-Id: <20210517134005.611251-2-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517134005.611251-1-tz.stoyanov@gmail.com> References: <20210517134005.611251-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. Signed-off-by: Tzvetomir Stoyanov (VMware) --- include/trace-cmd/trace-cmd.h | 2 ++ lib/trace-cmd/trace-util.c | 24 ++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/include/trace-cmd/trace-cmd.h b/include/trace-cmd/trace-cmd.h index 7305487c..6984db86 100644 --- a/include/trace-cmd/trace-cmd.h +++ b/include/trace-cmd/trace-cmd.h @@ -43,4 +43,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/trace-util.c b/lib/trace-cmd/trace-util.c index 049fe049..6db754e4 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,19 +355,36 @@ trace_load_plugins(struct tep_handle *tep, int flags) return list; } +/** + * 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 __weak 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, true, fmt, ap); va_end(ap); } -void tracecmd_info(const char *fmt, ...) +void __weak 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, false, fmt, ap); va_end(ap); @@ -379,6 +396,9 @@ void __weak 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, true, fmt, ap); va_end(ap); From patchwork Mon May 17 13:40:01 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: 12261993 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,URIBL_BLOCKED, 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 86652C43461 for ; Mon, 17 May 2021 13:40:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5C367610E9 for ; Mon, 17 May 2021 13:40:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237425AbhEQNl1 (ORCPT ); Mon, 17 May 2021 09:41:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237414AbhEQNl0 (ORCPT ); Mon, 17 May 2021 09:41:26 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83DDFC061573 for ; Mon, 17 May 2021 06:40:10 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id et19so2206756ejc.4 for ; Mon, 17 May 2021 06:40:10 -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=MhaNQMLEk3FzjpKjnPZiq4qO19h0lLl+kHtcI51ICRM=; b=TuP2oPLz9LQHMlHd9O+eaxt+h4D3ytdYDUIttCAqJtfngv7nMoHXuyLzNZz7m+uQxD mzEqIB+1aUGmVYFdO4EJeg+eknwH2rERF6g8OwsBx4roxuFkXODxXXs+eLir06Y77vW1 WhS1pxyw46bHgjuTdh5Ae+kMp2s6yBm04oKdGiByhCYr8KQ6siCJSnJd7e4RCRJSzi9P zt+pEAGYJvue+ftDaE7SufyoMligXBOutpx52mep4IPoS9br7T+D/QzitLY0ZrPIJXcZ xSFfM7JltmHYD5rh4TxO7wfV244fGLO+ujnTHsh/SvNC3zhuRP3AaivXkITyHzll904M 4XLg== 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=MhaNQMLEk3FzjpKjnPZiq4qO19h0lLl+kHtcI51ICRM=; b=r0NsrOEV/FH9VwllOOddSa9DHwsh7hmyzuA8rrn6FIvCkJIviBD7a+fZC00ZGsRzGH BgxqrPDD1lYSzTbdegNF6Q5lQLppCQqY+78jG/nLSe88s1CnaXxR9IqySKAkkF9JJbUM ctWa/cObahdERTfFuj9mSi+atMtkyigJIL12HSEHOCuqvvZpomdiZj/jpiiIVriBjhQ/ Rd7ideIkMaY/dQkd4g5bpQQINF7xaAthsErwGDikEI28tcgKjuVnaiXr1akwrptSHjmV Zo+SbFvoJ1+encncZwpVytA5xqLqAUCEsH7AVgOsjZmWXkx1zf52ELKFTzwBUvrYXQHo NdQg== X-Gm-Message-State: AOAM532MQfU1PBYDJIToYFFj+sGERmM+mceGDTslSQyVAKZycH+ekN1I 0KQb5jEuAPK6XXLCPIbw+Bk= X-Google-Smtp-Source: ABdhPJwrSwysw1sT0WC8lt7TnpVncaDrKpHX98yhzUc8TuEiagPU3RGoopT2MNOEZyFFC2zH8a0xQA== X-Received: by 2002:a17:906:bb0e:: with SMTP id jz14mr61585986ejb.285.1621258809318; Mon, 17 May 2021 06:40:09 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id r25sm10961799edv.78.2021.05.17.06.40.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 06:40:08 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 2/6] trace-cmd library: Document the API for log levels Date: Mon, 17 May 2021 16:40:01 +0300 Message-Id: <20210517134005.611251-3-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517134005.611251-1-tz.stoyanov@gmail.com> References: <20210517134005.611251-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 Mon May 17 13:40:02 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: 12261995 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.8 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 7C4FBC433ED for ; Mon, 17 May 2021 13:40:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 638D1611BD for ; Mon, 17 May 2021 13:40:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237426AbhEQNl2 (ORCPT ); Mon, 17 May 2021 09:41:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237414AbhEQNl1 (ORCPT ); Mon, 17 May 2021 09:41:27 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63256C061573 for ; Mon, 17 May 2021 06:40:11 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id di13so6959668edb.2 for ; Mon, 17 May 2021 06:40:11 -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=yXcjd1VSx2FcFrHV2TYzupMqnptDEgXSHYvfrFfjJ9s=; b=guGC5uE/Lw2B/fp+D4BGYpBsnT2QQl/3rU1+HsXszxiRKCupbZWyYdbUHYMWKo0b9U 8HVdJ8jRMy/Oq8s8k3xp1aRkf+2tURP5Zu8aCLqZv98RMFIYLEwavWDBdvtpjVTZ2dxD aJiiMUC3fT7FVvJMVreTdaSkk7vEAnwcg2QcsIYW8BhIxPhL2I6aMkuCfGcDcNG1kJjy FWCSreYak86d7RL//NpyWILQAg/yAx2OhDciKs4ItXTDeFrdDpS6c47jWD3ktsSkx/+h 1FJ28k5PgECiOBTi5dqin0rY4sDgSuXcydN0BJMOzdJPcRpsyDC6ynQX/dzAXht33WPs PfRA== 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=yXcjd1VSx2FcFrHV2TYzupMqnptDEgXSHYvfrFfjJ9s=; b=bZ32wHPEZ4iy7AkmWesZ7m8cL23/IRCJOv2ifQkdp1Ndu402UZ7WOYJHZE6jujfGVh prOj3X8UFXFn+Ot+KvN9VHqSXWnLlR9cc9/i9myx3ZTQI/MIqIC3JkN6i7PBThi6XcmB M6u1MmrHJefbsET19hl+0eSmxOwj5WvRGoqMTnetkovDZEL2hYZXHBMB+M/h8dpKbe6e wLNWY1Kk45iX2WYEFiSNsJMzL02KB7Giq9dyJbHRE9c3rGCwqPL6+rQPbbQdDTfDl6wr QfSSkx34Pwf7JW+FFu+mMSkL2hIoHdVgEOglUjf/v18V+I0xx39JrRA5Vi78W8jC2UvO 2ANg== X-Gm-Message-State: AOAM5302WyLyWRrD3XF+7pgJa4H+5pLfEkLeraKzIzDT9LzsBgMLW1I5 8X888Hz2D9esLmWzIpCsFNY= X-Google-Smtp-Source: ABdhPJw5CuhTKzWa5G0Lz0AIjwwdzamj8IKVy4amzr/fTPBG9troNOMyPX5DtwB0EAntyG7jBhF51g== X-Received: by 2002:aa7:d890:: with SMTP id u16mr65005edq.49.1621258810157; Mon, 17 May 2021 06:40:10 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id r25sm10961799edv.78.2021.05.17.06.40.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 06:40:09 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 3/6] trace-cmd library: Renamed tracecmd_fatal() to tracecmd_critical() Date: Mon, 17 May 2021 16:40:02 +0300 Message-Id: <20210517134005.611251-4-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517134005.611251-1-tz.stoyanov@gmail.com> References: <20210517134005.611251-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 cd868f60..821b5cdb 100644 --- a/lib/trace-cmd/include/trace-cmd-local.h +++ b/lib/trace-cmd/include/trace-cmd-local.h @@ -11,7 +11,7 @@ /* Can be overridden */ 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 2e519752..5ee69b14 100644 --- a/lib/trace-cmd/trace-input.c +++ b/lib/trace-cmd/trace-input.c @@ -1105,7 +1105,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; } @@ -1166,7 +1166,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; } @@ -1176,7 +1176,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; } @@ -1375,7 +1375,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; } @@ -1383,7 +1383,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; } @@ -1949,7 +1949,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 6db754e4..be9fcf0e 100644 --- a/lib/trace-cmd/trace-util.c +++ b/lib/trace-cmd/trace-util.c @@ -390,8 +390,7 @@ void __weak tracecmd_info(const char *fmt, ...) va_end(ap); } - -void __weak tracecmd_fatal(const char *fmt, ...) +void __weak 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 Mon May 17 13:40:03 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: 12261997 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.8 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 B9B02C433B4 for ; Mon, 17 May 2021 13:40:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A2E2A6121F for ; Mon, 17 May 2021 13:40:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237427AbhEQNl3 (ORCPT ); Mon, 17 May 2021 09:41:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237414AbhEQNl2 (ORCPT ); Mon, 17 May 2021 09:41:28 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AAB7C061573 for ; Mon, 17 May 2021 06:40:12 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id n2so9262840ejy.7 for ; Mon, 17 May 2021 06:40:12 -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=DE7IG0BcWFqttkSphNV6FPXme57AvRKb/PS7r+vk3bk=; b=k1hiyA6EuXnP2IHdHntTzY4XCVFZRgfXYCS/uYUku8n/LFtTsFIrgkNOqv91J97OuZ Nh7Fu+2exYXhbYcJ+kuXXmhU6ABNn6ZxauYb+yIo9d44tNz1ESEeU1raQNw1j3sKAo3G VmrAadv5DwZkQqnrjHiKk+Rz9RKst8xg7Dhk5UQH2RqxM0zv02tKDGqLT/HLoj6fVUJg DqGIGySF4KK7GkiblZ8CUApjitqQq+2kxm7GCZkkSikr6yFGZrcrj0efhkNn/Zcb+W/v V9vyxaOzmKb5d1ikfAiKTdZduYssBj+d0XaX70YGlUq16bAetLrC8fE7879IanG6TC3p w4qQ== 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=DE7IG0BcWFqttkSphNV6FPXme57AvRKb/PS7r+vk3bk=; b=Ed5gEHSBU8UqLpAYSE0GvwauNXa3w8If/bofFGFEBRlOQwiRG7yWl9ta7m3mZ5bBLS S7aZxCVM4NxiXR+innXDinr/nru8HZN3aRJaw1t7fywl8p1Xc0a6rjllhLWej5mbAGHO ojVi1euTCI4V3ditv8b6OvZEyTvS44U4rKLSj61JaBILn6yQc8LhC7OoeAWTIotR6zG4 BS6Gq05nZkwUMgHsiNuCH/nnMAEoy37jX1FcfdjdxDBLN1Oo4lnG8rCBqLvz/4BTQi2K TxQiQA5sqV5+MQvCXIIwcVbBqkACa145gxeuq9MI/kV4FREi6p4dJ7hyCRYD8T75TKr0 rNsA== X-Gm-Message-State: AOAM532lCZKruDUq6AqsGm/AekqN8PQdnzWs+12gTvzqUVTmxq3NE3op 3qt+KwmhJsClchjFPZAEWws= X-Google-Smtp-Source: ABdhPJzq2FOEIvZPpyj+Fbug0QqmY0l+sATywr0KNJczunI61at1PgkH1D8WIbjKqx5qmmFL+Gda6w== X-Received: by 2002:a17:906:44c:: with SMTP id e12mr18421056eja.57.1621258811228; Mon, 17 May 2021 06:40:11 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id r25sm10961799edv.78.2021.05.17.06.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 06:40:10 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 4/6] trace-cmd library: Set debug log level in debug mode Date: Mon, 17 May 2021 16:40:03 +0300 Message-Id: <20210517134005.611251-5-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517134005.611251-1-tz.stoyanov@gmail.com> References: <20210517134005.611251-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 be9fcf0e..b65f9dec 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 Mon May 17 13:40:04 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: 12261999 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.8 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 5B256C43460 for ; Mon, 17 May 2021 13:40:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C36561185 for ; Mon, 17 May 2021 13:40:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237428AbhEQNla (ORCPT ); Mon, 17 May 2021 09:41:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237414AbhEQNl3 (ORCPT ); Mon, 17 May 2021 09:41:29 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6355EC061573 for ; Mon, 17 May 2021 06:40:13 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id l4so9252870ejc.10 for ; Mon, 17 May 2021 06:40:13 -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=z0LcYKshq465WgeE8dPD2Nn0zo3Dp6s7Ui2Y7fj6Jpk=; b=pJ9Mm0ilHuYkVp2HG4hI+D4+m2E4vfzKd9YjC/rJMhGJzqLlIe8hy4eG3lD8cgTqJz w8zHmhmc1mKrZXK+Xy43SQl3s23ozgcPti6i0BO6SdIvZDCI9X31ZObFvP+HrwKkBTt7 +GOyjS2iI8njOU2FsP1i8wFnz8nPDIeOQMe+cqN5XaY7szJdOC/ep9qU5VG00jUG+iQw jBUb8I9RxEvxLcMnLFB+Z7oRQqlJoHYqsB0YvpQ6bCvC5yXlSB03ymhLmqZhvj/knc+p lD4jqjKqSH7PCS1M7B5m0LD75sR56uw4IDjK2WlcHKHYLBO5V2YY/sDR8HRzIsJE8S2E YYmg== 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=z0LcYKshq465WgeE8dPD2Nn0zo3Dp6s7Ui2Y7fj6Jpk=; b=Pe8SiBhQlOCBD/TGG/xlUcdYNO1OantPNnYXUln2BHSA+nJ4jdjjUZY+ejyBWc10Sc I3aiQ9vpdRWIKQd+kG4yffXylSOenEt48X8KJDEmh+RErIu3tY+eJJ1px3ImCCvjdmoR 1MuCSfSH2NyRhSp5vJGZfgCZQyAc5U+yuwTCjwzf+Sx8DM55oVp4wlPgB3/BlXYXhRJi +SPOLqSGg3DB9aVVDjGi7xj+3kSp6X1ESmQmfdmrHR/hhFt5OoZDXQSTCpdFeDRegiSr P5zIE8AohTEIGACVPSL8gODqpHD3k80tJSrYszb0FLclKpFcChgjpGFevV6XiLIv5+AQ Ie7g== X-Gm-Message-State: AOAM5329LaCy9m4WV+SO5ucekak58q/wxdKbsCva1TULvqJbKbsNcqzn l3tUapdbXmwa9wMtJTseW8Uf8ZBuJU5b1g== X-Google-Smtp-Source: ABdhPJwcZgjHntXS50zrcB4KOWuM0UHf4XzeOCbuFFeapr4guDXHQu+QX1gqw25ZHngcbyuXzLWGCg== X-Received: by 2002:a17:906:3e52:: with SMTP id t18mr4119923eji.521.1621258812149; Mon, 17 May 2021 06:40:12 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id r25sm10961799edv.78.2021.05.17.06.40.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 06:40:11 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 5/6] trace-cmd report: Set the log level with -V and -q options Date: Mon, 17 May 2021 16:40:04 +0300 Message-Id: <20210517134005.611251-6-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517134005.611251-1-tz.stoyanov@gmail.com> References: <20210517134005.611251-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 b315283e..0cf6e773 100644 --- a/tracecmd/trace-read.c +++ b/tracecmd/trace-read.c @@ -1703,9 +1703,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 Mon May 17 13:40:05 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: 12262001 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.8 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 76E43C433B4 for ; Mon, 17 May 2021 13:40:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5AF0D611BF for ; Mon, 17 May 2021 13:40:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237429AbhEQNlb (ORCPT ); Mon, 17 May 2021 09:41:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237414AbhEQNla (ORCPT ); Mon, 17 May 2021 09:41:30 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EF33C061573 for ; Mon, 17 May 2021 06:40:14 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id lz27so9245608ejb.11 for ; Mon, 17 May 2021 06:40:14 -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=yNQWqk+0Vcd131/VdVAxcd/19bSFyi3YCa/nRH/QYv8=; b=MrzJd5AquJY2q4xLTy9+2q7GECm8nmMDSwfnn2EBSQpNahQuUIB8812lwDNB5WwpVd prWt/6bq4U7uafGtXXqnS5yXEVnKxFGs/1ohJLngo3I3AI/3W/kdYkSQgiBgpzH9Qq2V /gGsKRGHbWFO4scBILkVmeNX1HSzBWhUqzEFM4JjFYkutygztPrjEVdzsTorE3FqPU8M JfwRNNLcM2pA9qFLItNAacOHtunG6lXJq7HDPTXBHOwkKxE8hvegj/qSf+v+HDGP9nxx m4ibtjumY3aREx+QbJutzZdn4q76QT/77xblWvcqewGJ9RsYxMkhc4gKHaXtL69eL6WA sMww== 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=yNQWqk+0Vcd131/VdVAxcd/19bSFyi3YCa/nRH/QYv8=; b=pRWforY2emECRoydrgK7/gz2uSzW5s9NUFyv0Q+RO0ITe5YTV10zWhj3JOyoAiqpAF qjpU2XPGYljRSGnMStkgkyIAoL02QZUYhM+btz38PfsaGOqlrmO30KdzycdverWJ9dfj irOJ6r84j/ycVuPHoKxfVRH5oA2Qxw9gZZld5ZgcZD89SnwOGiQir6IVuKYa7VY6+2jI ueEQxNessVYgs7I6D/KqndPOwTPlqMOuQPGMA+Grp44/FAKnjsXmO93H2/q/idKTYvhq QMRK8mWq15Tf2jbtF5xhl/VLyPI9bJ4Akiy+48h280PXmCNhUsSgU9lri5Od5j+HGA67 6Urg== X-Gm-Message-State: AOAM531j7C+O1hRVXU5MdNuT56u5cCrI9SBiMRa6cQSF1TfXXgehVhs0 7EavwYPQ9sm4xotvTs80voQsagN23qPEWg== X-Google-Smtp-Source: ABdhPJy2S1pGnZdT6Lxl0XJSPWcIbcc7pHywa8wBI19vW6/xZWyekUxfEUw6PskszU3lnY8/51YG3w== X-Received: by 2002:a17:906:2e82:: with SMTP id o2mr4968849eji.388.1621258813202; Mon, 17 May 2021 06:40:13 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id r25sm10961799edv.78.2021.05.17.06.40.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 06:40:12 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 6/6] trace-cmd: Add new function to set log level Date: Mon, 17 May 2021 16:40:05 +0300 Message-Id: <20210517134005.611251-7-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517134005.611251-1-tz.stoyanov@gmail.com> References: <20210517134005.611251-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 | 40 ++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/tracecmd/include/trace-local.h b/tracecmd/include/trace-local.h index 4c5669c9..e9a0aea8 100644 --- a/tracecmd/include/trace-local.h +++ b/tracecmd/include/trace-local.h @@ -39,6 +39,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..00cdaa37 100644 --- a/tracecmd/trace-cmd.c +++ b/tracecmd/trace-cmd.c @@ -45,6 +45,46 @@ void *malloc_or_die(unsigned int size) return data; } +static struct trace_log_severity { + int id; + const char *name; +} log_severity[] = { + { .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 = ARRAY_SIZE(log_severity); + int i; + + for (i = 0; i < size; i++) { + if (!strncmp(level, log_severity[i].name, strlen(log_severity[i].name))) { + tracecmd_set_loglevel(log_severity[i].id); + return 0; + } + } + } + + return -1; +} /** * struct command