From patchwork Wed Apr 28 07:29:58 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: 12228225 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 2DEF4C43460 for ; Wed, 28 Apr 2021 07:30:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DCF81613D8 for ; Wed, 28 Apr 2021 07:30:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236430AbhD1Hav (ORCPT ); Wed, 28 Apr 2021 03:30:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230317AbhD1Hau (ORCPT ); Wed, 28 Apr 2021 03:30:50 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAFA4C061574 for ; Wed, 28 Apr 2021 00:30:05 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id w3so93162712ejc.4 for ; Wed, 28 Apr 2021 00:30:05 -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=+eigHkpaNbg45Tt4TdTfL0tA6GwEZIfvUmL0kqbGThA=; b=r+8FOFL6Fp9vdErw7g7CQ1nLW3ViTCw6MglX/fB84GuxZr6KupPgXYrxqrptElnJTo nRxzZHemPqcKeYwJgzp2j3m/nMe4t8tzzRIL3o1sBqNB/lJjuiRZ58VKz1OBppkcFHWV uoz81kopzP/eIoPSo/zfjJwXABELydUqqt6H6bOlGesWtR3AjFeT19TOCx+bmbnbgj0O 63wgNHVCv4WpiWFKyp5l9wW5O7i8S9jrX/wUzVbJuxaNy036WggWLMm1a4Ih1LEllIGI pGPC3Bfb7LsBUEMEeLuIhRvVy+97QBnlx9NpzcFh+ZvKl8O089HTkkZTomquXD6Xo7mb IS2g== 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=+eigHkpaNbg45Tt4TdTfL0tA6GwEZIfvUmL0kqbGThA=; b=d38K9vqmec+TwBYhbcfBJTDZsQ7jf1rNVd53TSg4r/WFkAcCk4/ikciISWrb7tr5Ws hlOx0LgXG3ciqpSQjh99/Rj4wnUDmyfwMH22E+Hrqn3UBVTecLKMlZJuD6I9mza/mMs8 Ccbg6OJQmxs8XzGMPChVV3C410XN/xZzRFRJX0rrNBGJR5uPfooGHt5WFs6J5sXpFrCG dqfz3O27v48gcPxILxRXLX0SdMwEnVxNhFFCJeDj2mPD0M2wBL3bewQaPw4NGEx62HgO AZgPt7P9gOLdxFtHLF/d4Rj62a88jnSxijoXYDotS48BfcpIRbWB3IFcBljuQLHPDltW T2fw== X-Gm-Message-State: AOAM531se3EwAeBAjthGcSJ4TQr3ZMb+gG/gq6IQlv4296Nux24SerXq UjZ1tybGT4oUdfo2nCjbqc4= X-Google-Smtp-Source: ABdhPJyhI70LU0zf6A23GenhBFw1ZBYyaAdKBPmRmh41yYOHhiFImh1lxhQ3Sy7Ndhe9+azEuHQjKA== X-Received: by 2002:a17:906:507:: with SMTP id j7mr10928054eja.151.1619595004609; Wed, 28 Apr 2021 00:30:04 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id dh6sm4274292edb.63.2021.04.28.00.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:30:04 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 1/4] libtraceevent: Add log levels Date: Wed, 28 Apr 2021 10:29:58 +0300 Message-Id: <20210428073001.755905-2-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210428073001.755905-1-tz.stoyanov@gmail.com> References: <20210428073001.755905-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Defined levels of the library logs and new API to set the desired log level. By default, only critical logs are enabled. Signed-off-by: Tzvetomir Stoyanov (VMware) --- src/event-parse.h | 12 ++++++++++++ src/parse-utils.c | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/event-parse.h b/src/event-parse.h index 05b156b..77be2b9 100644 --- a/src/event-parse.h +++ b/src/event-parse.h @@ -749,4 +749,16 @@ int tep_filter_copy(struct tep_event_filter *dest, struct tep_event_filter *sour int tep_filter_compare(struct tep_event_filter *filter1, struct tep_event_filter *filter2); +/* Control library logs */ +enum tep_loglevel { + TEP_LOG_NONE = 0, + TEP_LOG_CRITICAL, + TEP_LOG_ERROR, + TEP_LOG_WARNING, + TEP_LOG_INFO, + TEP_LOG_DEBUG, + TEP_LOG_ALL +}; +void tep_set_loglevel(enum tep_loglevel level); + #endif /* _PARSE_EVENTS_H */ diff --git a/src/parse-utils.c b/src/parse-utils.c index 6a4a2cd..bc89c44 100644 --- a/src/parse-utils.c +++ b/src/parse-utils.c @@ -9,8 +9,21 @@ #include #include +#include "event-parse.h" + #define __weak __attribute__((weak)) +static int log_level = TEP_LOG_CRITICAL; + +/** + * tep_set_loglevel - set log level of the library + * @level: desired level of the library messages + */ +void tep_set_loglevel(enum tep_loglevel level) +{ + log_level = level; +} + int __weak tep_vwarning(const char *name, const char *fmt, va_list ap) { int ret = errno; @@ -29,6 +42,9 @@ void __weak tep_warning(const char *fmt, ...) { va_list ap; + if (log_level < TEP_LOG_WARNING) + return; + va_start(ap, fmt); tep_vwarning("libtraceevent", fmt, ap); va_end(ap); From patchwork Wed Apr 28 07:29:59 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: 12228227 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 88E5AC433ED for ; Wed, 28 Apr 2021 07:30:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 536E3600D4 for ; Wed, 28 Apr 2021 07:30:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230317AbhD1Haw (ORCPT ); Wed, 28 Apr 2021 03:30:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230145AbhD1Hav (ORCPT ); Wed, 28 Apr 2021 03:30:51 -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 F3112C061574 for ; Wed, 28 Apr 2021 00:30:06 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id u21so93141549ejo.13 for ; Wed, 28 Apr 2021 00:30:06 -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=8HuFWNZvUbEQt+HXbmP/jdGZc/zIp99hePuygD6I6ow=; b=q+XPm/vW839b+YUxnhyDEmN8sVozn2PkSMArA1It1CYhJ15SIW1QUS4sp8cR4uW1Kb TLjPu1QRSVynoXOyzMGOUWHogKvT+swlZp+dVfNR7mNuRXN/YQ3LC/Q5E13KKCf4SFuw 4vxGcHq4h77uY3cIN4eeXeNiD7UASIAcJw9zGtd6HrHI09HzVVcOkV0ZZjCgkhlgAQa5 5567M8QzOCQ+fxq49aCqZz2cXz/61bWeZkL0KfSk1J8OQWYARDgRapjW/WsNdz4d8Af9 pkpJ/f7nOJCM4CJIqHwcHs1lXDcYagFdLLaLvjKTZbSPaUlMTJ4cZcudLr3xHtA9YcON z5Fg== 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=8HuFWNZvUbEQt+HXbmP/jdGZc/zIp99hePuygD6I6ow=; b=Z9cHcgf07SpNhKUhIFKzZK/7aRAMCTFpFPAiK6hPc0WqozKqWxfen01kzECWdh2LQT FCTn+w6K4sIuAmWgiyHkGogZ8gZM4hYCdCPxYlxUB8R3m8qIqfIewsIBEf/laRr5LvwI OGPv0VXwvb74x3jEx9Hh1CofGTQuA+obgKGgqHhKJWY6R8b3GZN6vmd7Hqo7lDJWqSl6 NtHg8lgmDUNHsvV8q/Hfwnu4uY31loDG6fG/V2YK53ohExIcwxf/XBxf/sKkoGvIe0Z7 QJBJ2OpKedUY+rIG7SbKm4QsKSS0Hau/PNqScfPhLdzqTym171LeckoLfGBkk+lmhz/z iVVw== X-Gm-Message-State: AOAM530Z2S89pRDxVULEgtd7rv3lZZjYNbNeU0+MHY0Xuwaezt90kWEn ZZmIyTc6idA00NDxx5dpzCU= X-Google-Smtp-Source: ABdhPJwAppB31FJ0ftIwG7CkQUhC56vaxBjEn7yX6GbDpOooZgl80+qYbn5mI3Q6tZiHW16QMYNb6A== X-Received: by 2002:a17:907:10d8:: with SMTP id rv24mr27094025ejb.542.1619595005729; Wed, 28 Apr 2021 00:30:05 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id dh6sm4274292edb.63.2021.04.28.00.30.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:30:05 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 2/4] libtraceevent: Add logs with severity info Date: Wed, 28 Apr 2021 10:29:59 +0300 Message-Id: <20210428073001.755905-3-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210428073001.755905-1-tz.stoyanov@gmail.com> References: <20210428073001.755905-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Renamed existing pr_stat() internal function to tep_info() and limit it to print only when the log level is TEP_LOG_INFO. Removed duplicated and unused functions: vpr_stat() __pr_stat() __vpr_stat() Signed-off-by: Tzvetomir Stoyanov (VMware) --- src/event-parse.c | 14 +++++++------- src/event-plugin.c | 2 +- src/event-utils.h | 7 +------ src/parse-utils.c | 24 ++++-------------------- 4 files changed, 13 insertions(+), 34 deletions(-) diff --git a/src/event-parse.c b/src/event-parse.c index 88ec909..97c1a97 100644 --- a/src/event-parse.c +++ b/src/event-parse.c @@ -6927,8 +6927,8 @@ static int find_event_handle(struct tep_handle *tep, struct tep_event *event) if (!(*next)) return 0; - pr_stat("overriding event (%d) %s:%s with new print handler", - event->id, event->system, event->name); + tep_info("overriding event (%d) %s:%s with new print handler", + event->id, event->system, event->name); event->handler = handle->func; event->context = handle->context; @@ -7404,7 +7404,7 @@ int tep_register_print_function(struct tep_handle *tep, * plugins updating the function. This overrides the * system defaults. */ - pr_stat("override of function helper '%s'", name); + tep_info("override of function helper '%s'", name); remove_func_handler(tep, name); } @@ -7542,8 +7542,8 @@ int tep_register_event_handler(struct tep_handle *tep, int id, if (event == NULL) goto not_found; - pr_stat("overriding event (%d) %s:%s with new print handler", - event->id, event->system, event->name); + tep_info("overriding event (%d) %s:%s with new print handler", + event->id, event->system, event->name); event->handler = func; event->context = context; @@ -7628,8 +7628,8 @@ int tep_unregister_event_handler(struct tep_handle *tep, int id, goto not_found; if (event->handler == func && event->context == context) { - pr_stat("removing override handler for event (%d) %s:%s. Going back to default handler.", - event->id, event->system, event->name); + tep_info("removing override handler for event (%d) %s:%s. Going back to default handler.", + event->id, event->system, event->name); event->handler = NULL; event->context = NULL; diff --git a/src/event-plugin.c b/src/event-plugin.c index df4a0a3..f42243f 100644 --- a/src/event-plugin.c +++ b/src/event-plugin.c @@ -497,7 +497,7 @@ load_plugin(struct tep_handle *tep, const char *path, list->name = plugin; *plugin_list = list; - pr_stat("registering plugin: %s", plugin); + tep_info("registering plugin: %s", plugin); func(tep); return; diff --git a/src/event-utils.h b/src/event-utils.h index ff4d6c4..1951557 100644 --- a/src/event-utils.h +++ b/src/event-utils.h @@ -9,15 +9,10 @@ #include #include +void tep_info(const char *fmt, ...); /* Can be overridden */ void tep_warning(const char *fmt, ...); int tep_vwarning(const char *name, const char *fmt, va_list ap); -void pr_stat(const char *fmt, ...); -void vpr_stat(const char *fmt, va_list ap); - -/* Always available */ -void __pr_stat(const char *fmt, ...); -void __vpr_stat(const char *fmt, ...); #define min(x, y) ({ \ typeof(x) _min1 = (x); \ diff --git a/src/parse-utils.c b/src/parse-utils.c index bc89c44..b997823 100644 --- a/src/parse-utils.c +++ b/src/parse-utils.c @@ -50,31 +50,15 @@ void __weak tep_warning(const char *fmt, ...) va_end(ap); } -void __vpr_stat(const char *fmt, va_list ap) -{ - vprintf(fmt, ap); - printf("\n"); -} -void __pr_stat(const char *fmt, ...) +void tep_info(const char *fmt, ...) { va_list ap; - va_start(ap, fmt); - __vpr_stat(fmt, ap); - va_end(ap); -} - -void __weak vpr_stat(const char *fmt, va_list ap) -{ - __vpr_stat(fmt, ap); -} - -void __weak pr_stat(const char *fmt, ...) -{ - va_list ap; + if (log_level < TEP_LOG_INFO) + return; va_start(ap, fmt); - __vpr_stat(fmt, ap); + tep_vwarning("libtraceevent", fmt, ap); va_end(ap); } From patchwork Wed Apr 28 07:30: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: 12228229 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 11AE7C433B4 for ; Wed, 28 Apr 2021 07:30:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C6D22600D4 for ; Wed, 28 Apr 2021 07:30:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230145AbhD1Hax (ORCPT ); Wed, 28 Apr 2021 03:30:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236448AbhD1Haw (ORCPT ); Wed, 28 Apr 2021 03:30:52 -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 01686C061574 for ; Wed, 28 Apr 2021 00:30:08 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id q6so13688039edr.3 for ; Wed, 28 Apr 2021 00:30:07 -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=zSOgWJ95EEp7A5+Wy9y/1qppCgR2i4QV4RIFIX7Utfg=; b=bwlLyRfVJXwVTJ+f4EG3GeDdaJ6AYtRlxW9mCBbuRNPQmCzsFvPhwDkjZ8Duv3BpjE E8y2BWl33DyjkpXwQKWJxJJb+gGQq8g/DjrrWTjhn8mBIewMYmkSunq+KLKQrowk48pM M81bRMQy29NpxsicnCOUOR4Au7FjS18Js28XebvK84TLGyCo3W/sbt4NFovDXLfb5r8y u56BDqqDCVoFKa09b/GBNcUQespzZJnkQU/5ZkUfiYLs8x4VtMJCHvcjgyKeFNc5Xnbl kYTDd1ItRjtx4bUhG+P1hnhu/icrakEbdj6MX1TCw/TQc6H/4cdcHXJo03aY8qAJCa80 A5Sg== 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=zSOgWJ95EEp7A5+Wy9y/1qppCgR2i4QV4RIFIX7Utfg=; b=DlIET+1r3iq6skdcjAJR/tRxjOft7QbGxLac345J/0/G2H1x7sD/Gx02n/bXESvlyd R3plTyiOvTuUJWiIET2EGGwL9RAdeNwrb/EgIK8+zGEVucYAbI8LDJlMcgehtMaTzdMa ZaJ9q5QRA+wEhXOpCxKN8jMYQNYYweQTs3gqazNlGVWhGqZgTqi5YJCovuM+jN9oxJMs iIT954dqznZi3Mh77GE2Jnq6smdnarRWswqWyVI8aGo+O8Jkef0AtgOQdTUYC6raDSEr F5eD8Zw8bLzcyrb7ECjXqK/6ndsA1qgekXWBtmbzY/B5tS9gCXjkPVYmSpeCL3fJRdkK S8xg== X-Gm-Message-State: AOAM533PwbbGam8TSLpmHwlktn2Z2v5hMo3kRZ/KjTz8XUwYVTrrKs/R 6aKRyr///uolRsDlCYtYx3mv6yr3LgcPKQ== X-Google-Smtp-Source: ABdhPJxJzvN0k6p+elnUlXHaQMxVMO1KZ4Kip8GpEUNbl7E0GhBXB6LxTny/AoHS3AhTRfM1t47FAw== X-Received: by 2002:a05:6402:350e:: with SMTP id b14mr9633994edd.307.1619595006817; Wed, 28 Apr 2021 00:30:06 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id dh6sm4274292edb.63.2021.04.28.00.30.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:30:06 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 3/4] libtraceevent: Rename tep_vwarning() to tep_vprint() Date: Wed, 28 Apr 2021 10:30:00 +0300 Message-Id: <20210428073001.755905-4-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210428073001.755905-1-tz.stoyanov@gmail.com> References: <20210428073001.755905-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Renamed the existing weak function tep_vwarning() to tep_vprint(), to match its purpose. This function is used to print library logs with any log severity, not only warnings. Signed-off-by: Tzvetomir Stoyanov (VMware) --- src/event-utils.h | 4 ++-- src/parse-utils.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/event-utils.h b/src/event-utils.h index 1951557..0e09838 100644 --- a/src/event-utils.h +++ b/src/event-utils.h @@ -9,10 +9,10 @@ #include #include +void tep_warning(const char *fmt, ...); void tep_info(const char *fmt, ...); /* Can be overridden */ -void tep_warning(const char *fmt, ...); -int tep_vwarning(const char *name, const char *fmt, va_list ap); +int tep_vprint(const char *name, enum tep_loglevel level, const char *fmt, va_list ap); #define min(x, y) ({ \ typeof(x) _min1 = (x); \ diff --git a/src/parse-utils.c b/src/parse-utils.c index b997823..b4e95b7 100644 --- a/src/parse-utils.c +++ b/src/parse-utils.c @@ -24,11 +24,11 @@ void tep_set_loglevel(enum tep_loglevel level) log_level = level; } -int __weak tep_vwarning(const char *name, const char *fmt, va_list ap) +int __weak tep_vprint(const char *name, enum tep_loglevel level, const char *fmt, va_list ap) { int ret = errno; - if (errno) + if (errno && level <= TEP_LOG_WARNING) perror(name); fprintf(stderr, " "); @@ -38,7 +38,7 @@ int __weak tep_vwarning(const char *name, const char *fmt, va_list ap) return ret; } -void __weak tep_warning(const char *fmt, ...) +void tep_warning(const char *fmt, ...) { va_list ap; @@ -46,7 +46,7 @@ void __weak tep_warning(const char *fmt, ...) return; va_start(ap, fmt); - tep_vwarning("libtraceevent", fmt, ap); + tep_vprint("libtraceevent", TEP_LOG_WARNING, fmt, ap); va_end(ap); } @@ -59,6 +59,6 @@ void tep_info(const char *fmt, ...) return; va_start(ap, fmt); - tep_vwarning("libtraceevent", fmt, ap); + tep_vprint("libtraceevent", TEP_LOG_INFO, fmt, ap); va_end(ap); } From patchwork Wed Apr 28 07:30: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: 12228231 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 5A0F2C433B4 for ; Wed, 28 Apr 2021 07:30:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2829C600D4 for ; Wed, 28 Apr 2021 07:30:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236522AbhD1Haz (ORCPT ); Wed, 28 Apr 2021 03:30:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236440AbhD1Hay (ORCPT ); Wed, 28 Apr 2021 03:30:54 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24C2AC061574 for ; Wed, 28 Apr 2021 00:30:09 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id t4so9825568ejo.0 for ; Wed, 28 Apr 2021 00:30: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=uwHG1/E4cyKYhRZxQpMx11UGXb1xtbdGpICLmcf3lag=; b=qrq/oVnpDwtQGbleFE54PozE9Fdsg9ugdVTX7NwnsnPQFLRJQ6sw3ehTCQnIziIlSB c0gbqW1ElGcKPEKLOCwj46pHaHqsq7vzI+45fXHW7QwF7ZhR3YCFthE5arBHtOcbfbHy jXjrdD2wweL7BJ15pTbfHp0O54ZuX2pUdIZepghcMUWu1H79Mcy7LWXoUrMJcmwr8Sos kC9onIV5g4RG8+x/HEmjelF1x2aP9/EfmHaWSjNpsTKmQot+QtPukk37e8ZceesbA7Xg 05z0yr4y3peZQ6dqLSS5Aa4BZjtqZWznufmpcvKB/cvE+edvq70lLRep6KrKC0C93ySt vojA== 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=uwHG1/E4cyKYhRZxQpMx11UGXb1xtbdGpICLmcf3lag=; b=PfimR+BCchyeGuhV3n9c8aGXeY120BaPFIvyw7p3NB6edyPnvyBerq8eK10Vrd2vUv Bp4vgSUjhWjU5kae5ASSj53YqYWqBLB5JV3zYMqDII90EsMHeaT6TXzgQaXjmTK2GdET uK73Kq2ogIJ06cB8uL+zzycVtVT9qVuI+8J5A0Jyf2s8wSz8e679xA8D6XfHrB/FdpQs /w53+KySrdrk+LzaD1ygINh0f+RVrjC6qn48b8mjBCciaQEDIjd4PCBO9z2UTc5z6XCp yUjJCD5QkQ9325E4Kc2XPkPmTH0+gJGBSakQHwLYBEa+LjQ6tnqAOjeJ1/dSwP5GJ7Hd h/UQ== X-Gm-Message-State: AOAM5337I/IsC+KpsmgYJFVbpD79kcyjrwQakbPYLjlZZOwd9lzvJWmD zHkdryeuEICSAfvDXOc4Rso= X-Google-Smtp-Source: ABdhPJz38+/LF6Jsa23xqtP+95Uw4p5h9NjdBAb4ZXSTtvZD2mJCMzqi8b9EPcIniD2DRYsTeNfdZg== X-Received: by 2002:a17:906:c04:: with SMTP id s4mr6741639ejf.170.1619595007795; Wed, 28 Apr 2021 00:30:07 -0700 (PDT) Received: from oberon.zico.biz ([83.222.187.186]) by smtp.gmail.com with ESMTPSA id dh6sm4274292edb.63.2021.04.28.00.30.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:30:07 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 4/4] libtraceevent: Document new log functionality Date: Wed, 28 Apr 2021 10:30:01 +0300 Message-Id: <20210428073001.755905-5-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210428073001.755905-1-tz.stoyanov@gmail.com> References: <20210428073001.755905-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Updated man pages with the new log API and log levels. Signed-off-by: Tzvetomir Stoyanov (VMware) --- Documentation/libtraceevent-log.txt | 90 +++++++++++++++++++++++++++++ Documentation/libtraceevent.txt | 3 + 2 files changed, 93 insertions(+) create mode 100644 Documentation/libtraceevent-log.txt diff --git a/Documentation/libtraceevent-log.txt b/Documentation/libtraceevent-log.txt new file mode 100644 index 0000000..0aee21d --- /dev/null +++ b/Documentation/libtraceevent-log.txt @@ -0,0 +1,90 @@ +libtraceevent(3) +================ + +NAME +---- +tep_set_loglevel - Set log level of the library + +SYNOPSIS +-------- +[verse] +-- +*#include * + +enum *tep_loglevel* { + TEP_LOG_NONE = 0, + TEP_LOG_CRITICAL, + TEP_LOG_ERROR, + TEP_LOG_WARNING, + TEP_LOG_INFO, + TEP_LOG_DEBUG, + TEP_LOG_ALL +}; + +int *tep_set_loglevel*(enum tep_loglevel _level_); + +-- +DESCRIPTION +----------- +The _tep_set_loglevel()_ function sets the level of the library logs that will be printed +on the console. Library log levels are: +[verse] +-- + _TEP_LOG_NONE_ - Do not print any logs. + _TEP_LOG_CRITICAL_ - Print critical logs, problem that may case a crash. + _TEP_LOG_ERROR_ - Print error logs, problem that could break the main logic of an API. + _TEP_LOG_WARNING_ - Print warnings, problem that could limit the result of an API. + _TEP_LOG_INFO_ - Print information about normal execution of an API. + _TEP_LOG_DEBUG_ - Print debug information. + _TEP_LOG_ALL_ - Print logs from all 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_. + + +EXAMPLE +------- +[source,c] +-- +#include + +tep_set_loglevel(TEP_LOG_ALL); +... +/* call libtraceevent APIs and observe any logs they produce */ +... +tep_set_loglevel(TEP_LOG_CRITICAL); +-- + +FILES +----- +[verse] +-- +*event-parse.h* + Header file to include in order to have access to the library APIs. +*-ltraceevent* + Linker switch to add when building a program that uses the library. +-- + +SEE ALSO +-------- +_libtraceevent(3)_, _trace-cmd(1)_ + +AUTHOR +------ +[verse] +-- +*Steven Rostedt* , author of *libtraceevent*. +*Tzvetomir Stoyanov* , author of this man page. +-- +REPORTING BUGS +-------------- +Report bugs to + +LICENSE +------- +libtraceevent is Free Software licensed under the GNU LGPL 2.1 + +RESOURCES +--------- +https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/ diff --git a/Documentation/libtraceevent.txt b/Documentation/libtraceevent.txt index 3365455..d42b5c9 100644 --- a/Documentation/libtraceevent.txt +++ b/Documentation/libtraceevent.txt @@ -127,6 +127,9 @@ Endian related APIs: bool *tep_is_local_bigendian*(struct tep_handle pass:[*]_tep_); void *tep_set_local_bigendian*(struct tep_handle pass:[*]_tep_, enum tep_endian _endian_); +Control library logs: + int *tep_set_loglevel*(enum tep_loglevel _level_); + Trace sequences: *#include * void *trace_seq_init*(struct trace_seq pass:[*]_s_);