From patchwork Wed Nov 6 09:48:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 11229835 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83822112B for ; Wed, 6 Nov 2019 09:49:18 +0000 (UTC) Received: from bastion.fedoraproject.org (bastion01.fedoraproject.org [209.132.181.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6167B2178F for ; Wed, 6 Nov 2019 09:49:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6167B2178F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=libteam-bounces@lists.fedorahosted.org Received: from mailman01.phx2.fedoraproject.org (mailman01.phx2.fedoraproject.org [10.5.126.36]) by bastion01.phx2.fedoraproject.org (Postfix) with ESMTP id CD4456061A8A; Wed, 6 Nov 2019 09:49:17 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 bastion01.phx2.fedoraproject.org CD4456061A8A Received: from mailman01.phx2.fedoraproject.org (localhost [IPv6:::1]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id C809A5AA79C98; Wed, 6 Nov 2019 09:49:17 +0000 (UTC) Received: by mailman01.phx2.fedoraproject.org (Postfix, from userid 991) id BD0275AA79C9A; Wed, 6 Nov 2019 09:49:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mailman01.phx2.fedoraproject.org X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=disabled version=3.4.0 Received: from smtp-mm-osuosl01.fedoraproject.org (smtp-mm-osuosl01.vpn.fedoraproject.org [192.168.1.23]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id 17F3B5AA79C98 for ; Wed, 6 Nov 2019 09:49:14 +0000 (UTC) Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by smtp-mm-osuosl01.fedoraproject.org (Postfix) with ESMTPS id CCE499806F for ; Wed, 6 Nov 2019 09:49:13 +0000 (UTC) Received: by mail-pf1-x441.google.com with SMTP id z4so12414112pfn.12 for ; Wed, 06 Nov 2019 01:49:13 -0800 (PST) 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=cRo1U4Pll3fqrYOnxyGmoFBM2obLRtsxL4ev2I67Ux8=; b=VYeGVZ87iIxPsXwoDNv2oOkAJMkk5UJ7KtxuYVqmsCxISyJnCwTNg6AFWs6FU8u05V 9cJ0fVIk/QFdnpkFo2ByIzJbZ7i7mUbBiQ60rKxfvhYe0jl5qJgPB+gjxXi7xVwKJjXW Hj6jp4I3Q1Om82hnn2HuDgDJStT8ZZNCbaRJukb6oEjz6fCY00VZMF4wrTC9msf/Kclo 45BRkibd4BXQuZuzpjpkGfenZG8lquXiHE0G6JQPUboHeToiMXnOKB7JRgJbSPwQeZx9 KHVrAMKGi3sYWP2a0Fx/0emjGQXMTe6GQm47T4ljfEbQoMvdV4UUK+4oqPkrmCswa4Cp Y2NQ== X-Gm-Message-State: APjAAAXNcBRZdNN2uP0Kq3yBG69HwqgoawmJuwXe8MQnxdS5e9Teo/Nh MopD5MzwDs+VEe3oYn7ru2xIt6LgqguP8g== X-Google-Smtp-Source: APXvYqyAoYtonEUuxRdeLHwjMHyh2PkAPaC9d/8HPd8jOjGvRcN/9BxjMo5haZmORUxUHtVf9SxixQ== X-Received: by 2002:a63:3281:: with SMTP id y123mr1871924pgy.252.1573033753023; Wed, 06 Nov 2019 01:49:13 -0800 (PST) Received: from dhcp-12-139.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id j11sm22249238pgk.3.2019.11.06.01.49.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2019 01:49:12 -0800 (PST) From: Hangbin Liu To: libteam@lists.fedorahosted.org Subject: [libteam PATCH 1/6] teamd/teamd.c: move teamd_log_dbg to teamd_log_dbgx Date: Wed, 6 Nov 2019 17:48:50 +0800 Message-Id: <20191106094855.13859-2-liuhangbin@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20191106094855.13859-1-liuhangbin@gmail.com> References: <20191106094855.13859-1-liuhangbin@gmail.com> MIME-Version: 1.0 Message-ID-Hash: MWCYMCGHLMLBAR4AV7IBEMF7WHVZ4TXB X-Message-ID-Hash: MWCYMCGHLMLBAR4AV7IBEMF7WHVZ4TXB X-MailFrom: liuhangbin@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Hangbin Liu , Jiri Pirko X-Mailman-Version: 3.1.1 Precedence: list List-Id: Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: As libdaemon do not filter log messages when we use syslog as output, all debug messages will be printed to the syslog even if we set daemon_verbosity_level to LOG_INFO. This would make user full confused and annoying. Since we have a -g option to enable debug message specially, let's move all teamd_log_dbg to teamd_log_dbgx so user could choose to print debug message or not. This patch will move all teamd_log_dbg to teamd_log_dbgx for teamd.c Signed-off-by: Hangbin Liu --- teamd/teamd.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/teamd/teamd.c b/teamd/teamd.c index 6c47312..34d4afa 100644 --- a/teamd/teamd.c +++ b/teamd/teamd.c @@ -332,8 +332,8 @@ static int teamd_run_loop_do_callbacks(struct list_item *lcb_list, fd_set *fds, if (err) { teamd_log_warn("Loop callback failed with: %s", strerror(-err)); - teamd_log_dbg("Failed loop callback: %s, %p", - lcb->name, lcb->priv); + teamd_log_dbgx(ctx, 1, "Failed loop callback: %s, %p", + lcb->name, lcb->priv); } } } @@ -519,7 +519,7 @@ static int __teamd_loop_callback_fd_add(struct teamd_context *ctx, list_add_tail(&ctx->run_loop.callback_list, &lcb->list); else list_add(&ctx->run_loop.callback_list, &lcb->list); - teamd_log_dbg("Added loop callback: %s, %p", lcb->name, lcb->priv); + teamd_log_dbgx(ctx, 1, "Added loop callback: %s, %p", lcb->name, lcb->priv); return 0; lcb_free: @@ -636,7 +636,7 @@ void teamd_loop_callback_del(struct teamd_context *ctx, const char *cb_name, list_del(&lcb->list); if (lcb->is_period) close(lcb->fd); - teamd_log_dbg("Removed loop callback: %s, %p", + teamd_log_dbgx(ctx, 1, "Removed loop callback: %s, %p", lcb->name, lcb->priv); free(lcb->name); free(lcb); @@ -645,7 +645,7 @@ void teamd_loop_callback_del(struct teamd_context *ctx, const char *cb_name, if (found) teamd_run_loop_restart(ctx); else - teamd_log_dbg("Callback named \"%s\" not found.", cb_name); + teamd_log_dbgx(ctx, 1, "Callback named \"%s\" not found.", cb_name); } int teamd_loop_callback_enable(struct teamd_context *ctx, const char *cb_name, @@ -820,7 +820,7 @@ static int teamd_set_hwaddr(struct teamd_context *ctx) if (err) return 0; /* addr is not defined in config, no change needed */ - teamd_log_dbg("Hwaddr string: \"%s\".", hwaddr_str); + teamd_log_dbgx(ctx, 1, "Hwaddr string: \"%s\".", hwaddr_str); err = parse_hwaddr(hwaddr_str, &hwaddr, &hwaddr_len); if (err) { teamd_log_err("Failed to parse hardware address."); @@ -953,16 +953,16 @@ static int teamd_runner_init(struct teamd_context *ctx) err = teamd_config_string_get(ctx, &runner_name, "$.runner.name"); if (err) { - teamd_log_dbg("Failed to get team runner name from config."); + teamd_log_dbgx(ctx, 1, "Failed to get team runner name from config."); runner_name = TEAMD_DEFAULT_RUNNER_NAME; err = teamd_config_string_set(ctx, runner_name, "$.runner.name"); if (err) { teamd_log_err("Failed to set default team runner name in config."); return err; } - teamd_log_dbg("Using default team runner \"%s\".", runner_name); + teamd_log_dbgx(ctx, 1, "Using default team runner \"%s\".", runner_name); } else { - teamd_log_dbg("Using team runner \"%s\".", runner_name); + teamd_log_dbgx(ctx, 1, "Using team runner \"%s\".", runner_name); } ctx->runner = teamd_find_runner(runner_name); if (!ctx->runner) { @@ -1108,12 +1108,12 @@ static void debug_log_port_list(struct teamd_context *ctx) char buf[120]; bool trunc; - teamd_log_dbg(""); + teamd_log_dbgx(ctx, 1, ""); team_for_each_port(port, ctx->th) { trunc = team_port_str(port, buf, sizeof(buf)); - teamd_log_dbg("%s %s", buf, trunc ? "" : ""); + teamd_log_dbgx(ctx, 1, "%s %s", buf, trunc ? "" : ""); } - teamd_log_dbg(""); + teamd_log_dbgx(ctx, 1, ""); } static void debug_log_option_list(struct teamd_context *ctx) @@ -1139,12 +1139,12 @@ static void debug_log_ifinfo_list(struct teamd_context *ctx) char buf[120]; bool trunc; - teamd_log_dbg(""); + teamd_log_dbgx(ctx, 1, ""); team_for_each_ifinfo(ifinfo, ctx->th) { trunc = team_ifinfo_str(ifinfo, buf, sizeof(buf)); - teamd_log_dbg("%s %s", buf, trunc ? "" : ""); + teamd_log_dbgx(ctx, 1, "%s %s", buf, trunc ? "" : ""); } - teamd_log_dbg(""); + teamd_log_dbgx(ctx, 1, ""); } static int debug_change_handler_func(struct team_handle *th, void *priv, @@ -1573,7 +1573,7 @@ static int teamd_generate_devname(struct teamd_context *ctx) if (err) return err; } while (ifindex); - teamd_log_dbg("Generated team device name \"%s\".", buf); + teamd_log_dbgx(ctx, 1, "Generated team device name \"%s\".", buf); ctx->team_devname = strdup(buf); if (!ctx->team_devname) @@ -1597,7 +1597,7 @@ static int teamd_get_devname(struct teamd_context *ctx, bool generate_enabled) } goto skip_set; } else { - teamd_log_dbg("Failed to get team device name from config."); + teamd_log_dbgx(ctx, 1, "Failed to get team device name from config."); if (generate_enabled) { err = teamd_generate_devname(ctx); if (err) { @@ -1617,7 +1617,7 @@ static int teamd_get_devname(struct teamd_context *ctx, bool generate_enabled) } skip_set: - teamd_log_dbg("Using team device \"%s\".", ctx->team_devname); + teamd_log_dbgx(ctx, 1, "Using team device \"%s\".", ctx->team_devname); err = asprintf(&ctx->ident, "%s_%s", ctx->argv0, ctx->team_devname); if (err == -1) { @@ -1835,9 +1835,9 @@ int main(int argc, char **argv) daemon_log_ident = ctx->ident; daemon_pid_file_proc = teamd_pid_file_proc; - teamd_log_dbg("Using PID file \"%s\"", daemon_pid_file_proc()); + teamd_log_dbgx(ctx, 1, "Using PID file \"%s\"", daemon_pid_file_proc()); if (ctx->config_file) - teamd_log_dbg("Using config file \"%s\"", ctx->config_file); + teamd_log_dbgx(ctx, 1, "Using config file \"%s\"", ctx->config_file); switch (ctx->cmd) { case DAEMON_CMD_HELP: