[5/6] teamd/teamd_link_watch.c: move teamd_log_dbg to teamd_log_dbgx
diff mbox series

Message ID 20191106094855.13859-6-liuhangbin@gmail.com
State New
Headers show
Series
  • move all teamd_log_dbg to teamd_log_dbgx
Related show

Commit Message

Hangbin Liu Nov. 6, 2019, 9:48 a.m. UTC
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_link_watch files.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 teamd/teamd_link_watch.c   | 14 +++++++-------
 teamd/teamd_lw_arp_ping.c  | 12 ++++++------
 teamd/teamd_lw_ethtool.c   |  4 ++--
 teamd/teamd_lw_nsna_ping.c |  2 +-
 teamd/teamd_lw_psr.c       | 12 ++++++------
 teamd/teamd_lw_tipc.c      |  8 ++++----
 6 files changed, 26 insertions(+), 26 deletions(-)

Patch
diff mbox series

diff --git a/teamd/teamd_link_watch.c b/teamd/teamd_link_watch.c
index 62f8267..7cf2185 100644
--- a/teamd/teamd_link_watch.c
+++ b/teamd/teamd_link_watch.c
@@ -281,8 +281,8 @@  static int link_watch_load_config_one(struct teamd_context *ctx,
 
 	err = team_get_port_user_linkup(ctx->th, tdport->ifindex, &linkup);
 	if (!err) {
-		teamd_log_dbg("%s: Current user link state is \"%s\".",
-			      tdport->ifname, linkup ? "up" : "down");
+		teamd_log_dbgx(ctx, 1, "%s: Current user link state is \"%s\".",
+			       tdport->ifname, linkup ? "up" : "down");
 	}
 
 	err = teamd_config_string_get(ctx, &link_watch_name,
@@ -351,8 +351,8 @@  static int link_watch_event_watch_port_added(struct teamd_context *ctx,
 	cpcookie = teamd_config_path_cookie_get(ctx, "$.ports.%s.link_watch",
 						tdport->ifname);
 	if (cpcookie) {
-		teamd_log_dbg("%s: Got link watch from port config.",
-			      tdport->ifname);
+		teamd_log_dbgx(ctx, 1, "%s: Got link watch from port config.",
+			       tdport->ifname);
 		err = link_watch_load_config(ctx, tdport, cpcookie);
 		if (err)
 			return err;
@@ -360,8 +360,8 @@  static int link_watch_event_watch_port_added(struct teamd_context *ctx,
 
 	cpcookie = teamd_config_path_cookie_get(ctx, "$.link_watch");
 	if (cpcookie) {
-		teamd_log_dbg("%s: Got link watch from global config.",
-			      tdport->ifname);
+		teamd_log_dbgx(ctx, 1, "%s: Got link watch from global config.",
+			       tdport->ifname);
 		err = link_watch_load_config(ctx, tdport, cpcookie);
 		if (err)
 			return err;
@@ -380,7 +380,7 @@  static int link_watch_event_watch_port_added(struct teamd_context *ctx,
 				      tdport->ifname);
 			return err;
 		}
-		teamd_log_dbg("%s: Using implicit link watch.", tdport->ifname);
+		teamd_log_dbgx(ctx, 1, "%s: Using implicit link watch.", tdport->ifname);
 		return link_watch_event_watch_port_added(ctx, tdport, priv);
 	}
 	return 0;
diff --git a/teamd/teamd_lw_arp_ping.c b/teamd/teamd_lw_arp_ping.c
index 81806f0..5eb46f9 100644
--- a/teamd/teamd_lw_arp_ping.c
+++ b/teamd/teamd_lw_arp_ping.c
@@ -178,7 +178,7 @@  static int lw_ap_load_options(struct teamd_context *ctx,
 	 * If source_host is not provided, just use address 0.0.0.0 according
 	 * to RFC 5227 (IPv4 Address Conflict Detection).
 	 */
-	teamd_log_dbg("source address \"%s\".",
+	teamd_log_dbgx(ctx, 1, "source address \"%s\".",
 		      str_in_addr(&ap_ppriv->src));
 
 	err = teamd_config_string_get(ctx, &host, "@.target_host", cpcookie);
@@ -189,25 +189,25 @@  static int lw_ap_load_options(struct teamd_context *ctx,
 	err = set_in_addr(&ap_ppriv->dst, host);
 	if (err)
 		return err;
-	teamd_log_dbg("target address \"%s\".", str_in_addr(&ap_ppriv->dst));
+	teamd_log_dbgx(ctx, 1, "target address \"%s\".", str_in_addr(&ap_ppriv->dst));
 
 	err = teamd_config_bool_get(ctx, &ap_ppriv->validate_active,
 				    "@.validate_active", cpcookie);
 	if (err)
 		ap_ppriv->validate_active = false;
-	teamd_log_dbg("validate_active \"%d\".", ap_ppriv->validate_active);
+	teamd_log_dbgx(ctx, 1, "validate_active \"%d\".", ap_ppriv->validate_active);
 
 	err = teamd_config_bool_get(ctx, &ap_ppriv->validate_inactive,
 				    "@.validate_inactive", cpcookie);
 	if (err)
 		ap_ppriv->validate_inactive = false;
-	teamd_log_dbg("validate_inactive \"%d\".", ap_ppriv->validate_inactive);
+	teamd_log_dbgx(ctx, 1, "validate_inactive \"%d\".", ap_ppriv->validate_inactive);
 
 	err = teamd_config_bool_get(ctx, &ap_ppriv->send_always,
 				    "@.send_always", cpcookie);
 	if (err)
 		ap_ppriv->send_always = false;
-	teamd_log_dbg("send_always \"%d\".", ap_ppriv->send_always);
+	teamd_log_dbgx(ctx, 1, "send_always \"%d\".", ap_ppriv->send_always);
 
 	err = teamd_config_int_get(ctx, &tmp, "@.vlanid", cpcookie);
 	if (!err) {
@@ -217,7 +217,7 @@  static int lw_ap_load_options(struct teamd_context *ctx,
 		}
 		ap_ppriv->vlanid_in_use = true;
 		ap_ppriv->vlanid = tmp;
-		teamd_log_dbg("vlan id \"%u\".", ap_ppriv->vlanid);
+		teamd_log_dbgx(ctx, 1, "vlan id \"%u\".", ap_ppriv->vlanid);
 	}
 
 	return 0;
diff --git a/teamd/teamd_lw_ethtool.c b/teamd/teamd_lw_ethtool.c
index 2010136..0cb6437 100644
--- a/teamd/teamd_lw_ethtool.c
+++ b/teamd/teamd_lw_ethtool.c
@@ -115,7 +115,7 @@  static int lw_ethtool_load_options(struct teamd_context *ctx,
 			teamd_log_err("\"delay_up\" must not be negative number.");
 			return -EINVAL;
 		}
-		teamd_log_dbg("delay_up \"%d\".", tmp);
+		teamd_log_dbgx(ctx, 1, "delay_up \"%d\".", tmp);
 		ms_to_timespec(&ethtool_ppriv->delay_up, tmp);
 	}
 	err = teamd_config_int_get(ctx, &tmp, "@.delay_down", cpcookie);
@@ -124,7 +124,7 @@  static int lw_ethtool_load_options(struct teamd_context *ctx,
 			teamd_log_err("\"delay_down\" must not be negative number.");
 			return -EINVAL;
 		}
-		teamd_log_dbg("delay_down \"%d\".", tmp);
+		teamd_log_dbgx(ctx, 1, "delay_down \"%d\".", tmp);
 		ms_to_timespec(&ethtool_ppriv->delay_down, tmp);
 	}
 	return 0;
diff --git a/teamd/teamd_lw_nsna_ping.c b/teamd/teamd_lw_nsna_ping.c
index 82371c4..6956f44 100644
--- a/teamd/teamd_lw_nsna_ping.c
+++ b/teamd/teamd_lw_nsna_ping.c
@@ -175,7 +175,7 @@  static int lw_nsnap_load_options(struct teamd_context *ctx,
 	err = set_sockaddr_in6(&nsnap_ppriv->dst, host);
 	if (err)
 		return err;
-	teamd_log_dbg("target address \"%s\".",
+	teamd_log_dbgx(ctx, 1, "target address \"%s\".",
 		      str_sockaddr_in6(&nsnap_ppriv->dst));
 
 	return 0;
diff --git a/teamd/teamd_lw_psr.c b/teamd/teamd_lw_psr.c
index ad6e56b..88246b7 100644
--- a/teamd/teamd_lw_psr.c
+++ b/teamd/teamd_lw_psr.c
@@ -46,9 +46,9 @@  static int lw_psr_callback_periodic(struct teamd_context *ctx, int events, void
 	} else {
 		psr_ppriv->missed++;
 		if (psr_ppriv->missed > psr_ppriv->missed_max && link_up) {
-			teamd_log_dbg("%s: Missed %u replies (max %u).",
-				      tdport->ifname, psr_ppriv->missed,
-				      psr_ppriv->missed_max);
+			teamd_log_dbgx(ctx, 1, "%s: Missed %u replies (max %u).",
+				       tdport->ifname, psr_ppriv->missed,
+				       psr_ppriv->missed_max);
 			link_up = false;
 		}
 	}
@@ -86,7 +86,7 @@  static int lw_psr_load_options(struct teamd_context *ctx,
 	} else {
 		tmp = LW_PSR_DEFAULT_INTERVAL;
 	}
-	teamd_log_dbg("interval \"%d\".", tmp);
+	teamd_log_dbgx(ctx, 1, "interval \"%d\".", tmp);
 	ms_to_timespec(&psr_ppriv->interval, tmp);
 
 	err = teamd_config_int_get(ctx, &tmp, "@.init_wait", cpcookie);
@@ -95,7 +95,7 @@  static int lw_psr_load_options(struct teamd_context *ctx,
 	/* if init_wait is set to 0, use default_init_wait */
 	if (err || !tmp)
 		psr_ppriv->init_wait = lw_psr_default_init_wait;
-	teamd_log_dbg("init_wait \"%d\".", timespec_to_ms(&psr_ppriv->init_wait));
+	teamd_log_dbgx(ctx, 1, "init_wait \"%d\".", timespec_to_ms(&psr_ppriv->init_wait));
 
 	err = teamd_config_int_get(ctx, &tmp, "@.missed_max", cpcookie);
 	if (!err) {
@@ -106,7 +106,7 @@  static int lw_psr_load_options(struct teamd_context *ctx,
 	} else {
 		tmp = LW_PSR_DEFAULT_MISSED_MAX;
 	}
-	teamd_log_dbg("missed_max \"%d\".", tmp);
+	teamd_log_dbgx(ctx, 1, "missed_max \"%d\".", tmp);
 	psr_ppriv->missed_max = tmp;
 
 	return 0;
diff --git a/teamd/teamd_lw_tipc.c b/teamd/teamd_lw_tipc.c
index 6d7277d..07b7cee 100644
--- a/teamd/teamd_lw_tipc.c
+++ b/teamd/teamd_lw_tipc.c
@@ -88,7 +88,7 @@  static int lw_tipc_link_state_change(struct teamd_context *ctx,
 		if (strcmp(link->name, lnr->linkname))
 			continue;
 		link->up = link_up;
-		teamd_log_dbg("tipc: link <%s> went %s.",
+		teamd_log_dbgx(ctx, 1, "tipc: link <%s> went %s.",
 			       lnr->linkname, link_up ? "up" : "down");
 check:
 		path_ok = lw_tipc_topology_check(priv, link->peer);
@@ -100,7 +100,7 @@  check:
 			      lnr->linkname);
 		return -EINVAL;
 	}
-	teamd_log_dbg("tipc: established new link <%s>", lnr->linkname);
+	teamd_log_dbgx(ctx, 1, "tipc: established new link <%s>", lnr->linkname);
 	link = malloc(sizeof(struct tipc_link));
 	if (!link)
 		return -ENOMEM;
@@ -153,7 +153,7 @@  static int lw_tipc_callback_socket(struct teamd_context *ctx, int events, void *
 	else if (event.event == htonl(TIPC_WITHDRAWN))
 		return lw_tipc_link_state_change(ctx, &lnr, tipc_ppriv, false);
 tipc_cb_err:
-	teamd_log_dbg("tipc: link state event error");
+	teamd_log_dbgx(ctx, 1, "tipc: link state event error");
 	return -EINVAL;
 }
 
@@ -234,7 +234,7 @@  static void lw_tipc_port_removed(struct teamd_context *ctx,
 	struct lw_tipc_port_priv *tipc_ppriv = priv;
 	struct tipc_link *link;
 
-	teamd_log_dbg("tipc port removed\n");
+	teamd_log_dbgx(ctx, 1, "tipc port removed\n");
 	teamd_loop_callback_del(ctx, LW_TIPC_TOPSRV_SOCKET, priv);
 	close(tipc_ppriv->topsrv_sock);
 	while (!LIST_EMPTY(&tipc_ppriv->links)) {