mgmtd, lib: Cleanup zlog_err()

Cleanup all zlog_err() that were meant for debug only.

Signed-off-by: Pushpasis Sarkar <pushpasis@gmail.com>
This commit is contained in:
Pushpasis Sarkar 2023-03-29 22:34:15 -07:00
parent 02619b5522
commit 048e1e7be8
3 changed files with 61 additions and 56 deletions

109
lib/vty.c
View File

@ -73,6 +73,13 @@ static bool mgmt_candidate_ds_wr_locked;
static uint64_t mgmt_client_id_next; static uint64_t mgmt_client_id_next;
static uint64_t mgmt_last_req_id = UINT64_MAX; static uint64_t mgmt_last_req_id = UINT64_MAX;
static bool vty_debug;
#define VTY_DBG(fmt, ...) \
do { \
if (vty_debug) \
zlog_debug(fmt, ##__VA_ARGS__); \
} while (0)
PREDECL_DLIST(vtyservs); PREDECL_DLIST(vtyservs);
struct vty_serv { struct vty_serv {
@ -3273,9 +3280,9 @@ void vty_init_vtysh(void)
static void vty_mgmt_server_connected(uintptr_t lib_hndl, uintptr_t usr_data, static void vty_mgmt_server_connected(uintptr_t lib_hndl, uintptr_t usr_data,
bool connected) bool connected)
{ {
zlog_err("%sGot %sconnected %s MGMTD Frontend Server", VTY_DBG("%sGot %sconnected %s MGMTD Frontend Server",
!connected ? "ERROR: " : "", !connected ? "dis: " : "", !connected ? "ERROR: " : "", !connected ? "dis: " : "",
!connected ? "from" : "to"); !connected ? "from" : "to");
mgmt_fe_connected = connected; mgmt_fe_connected = connected;
@ -3295,15 +3302,13 @@ static void vty_mgmt_session_created(uintptr_t lib_hndl, uintptr_t usr_data,
vty = (struct vty *)session_ctx; vty = (struct vty *)session_ctx;
if (!success) { if (!success) {
zlog_err("%s session for client %llu failed!", zlog_err("%s session for client %" PRIu64 " failed!",
create ? "Creating" : "Destroying", create ? "Creating" : "Destroying", client_id);
(unsigned long long)client_id);
return; return;
} }
zlog_err("%s session for client %llu successfully!", VTY_DBG("%s session for client %" PRIu64 " successfully",
create ? "Created" : "Destroyed", create ? "Created" : "Destroyed", client_id);
(unsigned long long)client_id);
if (create) if (create)
vty->mgmt_session_id = session_id; vty->mgmt_session_id = session_id;
} }
@ -3320,13 +3325,13 @@ static void vty_mgmt_ds_lock_notified(uintptr_t lib_hndl, uintptr_t usr_data,
vty = (struct vty *)session_ctx; vty = (struct vty *)session_ctx;
if (!success) { if (!success) {
zlog_err("%socking for DS %u failed! Err: '%s'", zlog_err("%socking for DS %u failed, Err: '%s'",
lock_ds ? "L" : "Unl", ds_id, errmsg_if_any); lock_ds ? "L" : "Unl", ds_id, errmsg_if_any);
vty_out(vty, "ERROR: %socking for DS %u failed! Err: '%s'\n", vty_out(vty, "ERROR: %socking for DS %u failed, Err: '%s'\n",
lock_ds ? "L" : "Unl", ds_id, errmsg_if_any); lock_ds ? "L" : "Unl", ds_id, errmsg_if_any);
} else { } else {
zlog_err("%socked DS %u successfully!", lock_ds ? "L" : "Unl", VTY_DBG("%socked DS %u successfully", lock_ds ? "L" : "Unl",
ds_id); ds_id);
} }
vty_mgmt_resume_response(vty, success); vty_mgmt_resume_response(vty, success);
@ -3342,17 +3347,15 @@ static void vty_mgmt_set_config_result_notified(
vty = (struct vty *)session_ctx; vty = (struct vty *)session_ctx;
if (!success) { if (!success) {
zlog_err( zlog_err("SET_CONFIG request for client 0x%" PRIx64
"SET_CONFIG request for client 0x%llx failed! Error: '%s'", " failed, Error: '%s'",
(unsigned long long)client_id, client_id, errmsg_if_any ? errmsg_if_any : "Unknown");
errmsg_if_any ? errmsg_if_any : "Unknown"); vty_out(vty, "ERROR: SET_CONFIG request failed, Error: %s\n",
vty_out(vty, "ERROR: SET_CONFIG request failed! Error: %s\n",
errmsg_if_any ? errmsg_if_any : "Unknown"); errmsg_if_any ? errmsg_if_any : "Unknown");
} else { } else {
zlog_err( VTY_DBG("SET_CONFIG request for client 0x%" PRIx64
"SET_CONFIG request for client 0x%llx req-id %llu was successfull!", " req-id %" PRIu64 " was successfull",
(unsigned long long)client_id, client_id, req_id);
(unsigned long long)req_id);
} }
vty_mgmt_resume_response(vty, success); vty_mgmt_resume_response(vty, success);
@ -3369,17 +3372,15 @@ static void vty_mgmt_commit_config_result_notified(
vty = (struct vty *)session_ctx; vty = (struct vty *)session_ctx;
if (!success) { if (!success) {
zlog_err( zlog_err("COMMIT_CONFIG request for client 0x%" PRIx64
"COMMIT_CONFIG request for client 0x%llx failed! Error: '%s'", " failed, Error: '%s'",
(unsigned long long)client_id, client_id, errmsg_if_any ? errmsg_if_any : "Unknown");
errmsg_if_any ? errmsg_if_any : "Unknown"); vty_out(vty, "ERROR: COMMIT_CONFIG request failed, Error: %s\n",
vty_out(vty, "ERROR: COMMIT_CONFIG request failed! Error: %s\n",
errmsg_if_any ? errmsg_if_any : "Unknown"); errmsg_if_any ? errmsg_if_any : "Unknown");
} else { } else {
zlog_err( VTY_DBG("COMMIT_CONFIG request for client 0x%" PRIx64
"COMMIT_CONFIG request for client 0x%llx req-id %llu was successfull!", " req-id %" PRIu64 " was successfull",
(unsigned long long)client_id, client_id, req_id);
(unsigned long long)req_id);
if (errmsg_if_any) if (errmsg_if_any)
vty_out(vty, "MGMTD: %s\n", errmsg_if_any); vty_out(vty, "MGMTD: %s\n", errmsg_if_any);
} }
@ -3399,19 +3400,18 @@ static enum mgmt_result vty_mgmt_get_data_result_notified(
vty = (struct vty *)session_ctx; vty = (struct vty *)session_ctx;
if (!success) { if (!success) {
zlog_err( zlog_err("GET_DATA request for client 0x%" PRIx64
"GET_DATA request for client 0x%llx failed! Error: '%s'", " failed, Error: '%s'",
(unsigned long long)client_id, client_id, errmsg_if_any ? errmsg_if_any : "Unknown");
errmsg_if_any ? errmsg_if_any : "Unknown"); vty_out(vty, "ERROR: GET_DATA request failed, Error: %s\n",
vty_out(vty, "ERROR: GET_DATA request failed! Error: %s\n",
errmsg_if_any ? errmsg_if_any : "Unknown"); errmsg_if_any ? errmsg_if_any : "Unknown");
vty_mgmt_resume_response(vty, success); vty_mgmt_resume_response(vty, success);
return MGMTD_INTERNAL_ERROR; return MGMTD_INTERNAL_ERROR;
} }
zlog_debug( VTY_DBG("GET_DATA request for client 0x%" PRIx64 " req-id %" PRIu64
"GET_DATA request for client 0x%llx req-id %llu was successfull!", " was successfull!",
(unsigned long long)client_id, (unsigned long long)req_id); client_id, req_id);
if (req_id != mgmt_last_req_id) { if (req_id != mgmt_last_req_id) {
mgmt_last_req_id = req_id; mgmt_last_req_id = req_id;
@ -3469,10 +3469,10 @@ int vty_mgmt_send_lockds_req(struct vty *vty, Mgmtd__DatastoreId ds_id,
vty->mgmt_req_id, ds_id, lock); vty->mgmt_req_id, ds_id, lock);
if (ret != MGMTD_SUCCESS) { if (ret != MGMTD_SUCCESS) {
zlog_err( zlog_err(
"Failed to send %sLOCK-DS-REQ to MGMTD for req-id %llu.", "Failed to send %sLOCK-DS-REQ to MGMTD for req-id %"
lock ? "" : "UN", PRIu64 ".",
(unsigned long long)vty->mgmt_req_id); lock ? "" : "UN", vty->mgmt_req_id);
vty_out(vty, "Failed to send %sLOCK-DS-REQ to MGMTD!", vty_out(vty, "Failed to send %sLOCK-DS-REQ to MGMTD!\n",
lock ? "" : "UN"); lock ? "" : "UN");
return -1; return -1;
} }
@ -3549,6 +3549,7 @@ int vty_mgmt_send_config_data(struct vty *vty)
MGMTD_DS_RUNNING) != MGMTD_SUCCESS) { MGMTD_DS_RUNNING) != MGMTD_SUCCESS) {
zlog_err("Failed to send %d Config Xpaths to MGMTD!!", zlog_err("Failed to send %d Config Xpaths to MGMTD!!",
(int)indx); (int)indx);
vty_out(vty, "Failed to send SETCFG-REQ to MGMTD!\n");
return -1; return -1;
} }
@ -3570,9 +3571,10 @@ int vty_mgmt_send_commit_config(struct vty *vty, bool validate_only, bool abort)
abort); abort);
if (ret != MGMTD_SUCCESS) { if (ret != MGMTD_SUCCESS) {
zlog_err( zlog_err(
"Failed to send COMMIT-REQ to MGMTD for req-id %llu.", "Failed to send COMMIT-REQ to MGMTD for req-id %"
(unsigned long long)vty->mgmt_req_id); PRIu64 ".",
vty_out(vty, "Failed to send COMMIT-REQ to MGMTD!"); vty->mgmt_req_id);
vty_out(vty, "Failed to send COMMIT-REQ to MGMTD!\n");
return -1; return -1;
} }
@ -3608,9 +3610,11 @@ int vty_mgmt_send_get_config(struct vty *vty, Mgmtd__DatastoreId datastore,
num_req); num_req);
if (ret != MGMTD_SUCCESS) { if (ret != MGMTD_SUCCESS) {
zlog_err("Failed to send GET-CONFIG to MGMTD for req-id %llu.", zlog_err(
(unsigned long long)vty->mgmt_req_id); "Failed to send GET-CONFIG to MGMTD for req-id %" PRIu64
vty_out(vty, "Failed to send GET-CONFIG to MGMTD!"); ".",
vty->mgmt_req_id);
vty_out(vty, "Failed to send GET-CONFIG to MGMTD!\n");
return -1; return -1;
} }
@ -3643,9 +3647,10 @@ int vty_mgmt_send_get_data(struct vty *vty, Mgmtd__DatastoreId datastore,
vty->mgmt_req_id, datastore, getreq, num_req); vty->mgmt_req_id, datastore, getreq, num_req);
if (ret != MGMTD_SUCCESS) { if (ret != MGMTD_SUCCESS) {
zlog_err("Failed to send GET-DATA to MGMTD for req-id %llu.", zlog_err("Failed to send GET-DATA to MGMTD for req-id %" PRIu64
(unsigned long long)vty->mgmt_req_id); ".",
vty_out(vty, "Failed to send GET-DATA to MGMTD!"); vty->mgmt_req_id);
vty_out(vty, "Failed to send GET-DATA to MGMTD!\n");
return -1; return -1;
} }

View File

@ -24,7 +24,7 @@
#define MGMTD_DS_DBG(fmt, ...) \ #define MGMTD_DS_DBG(fmt, ...) \
do { \ do { \
if (mgmt_debug_ds) \ if (mgmt_debug_ds) \
zlog_err("%s: " fmt, __func__, ##__VA_ARGS__); \ zlog_debug("%s: " fmt, __func__, ##__VA_ARGS__); \
} while (0) } while (0)
#define MGMTD_DS_ERR(fmt, ...) \ #define MGMTD_DS_ERR(fmt, ...) \
zlog_err("%s: ERROR: " fmt, __func__, ##__VA_ARGS__) zlog_err("%s: ERROR: " fmt, __func__, ##__VA_ARGS__)

View File

@ -20,10 +20,10 @@
#define MGMTD_TXN_ERR(fmt, ...) \ #define MGMTD_TXN_ERR(fmt, ...) \
fprintf(stderr, "%s: ERROR, " fmt "\n", __func__, ##__VA_ARGS__) fprintf(stderr, "%s: ERROR, " fmt "\n", __func__, ##__VA_ARGS__)
#else /* REDIRECT_DEBUG_TO_STDERR */ #else /* REDIRECT_DEBUG_TO_STDERR */
#define MGMTD_TXN_DBG(fmt, ...) \ #define MGMTD_TXN_DBG(fmt, ...) \
do { \ do { \
if (mgmt_debug_txn) \ if (mgmt_debug_txn) \
zlog_err("%s: " fmt, __func__, ##__VA_ARGS__); \ zlog_debug("%s: " fmt, __func__, ##__VA_ARGS__); \
} while (0) } while (0)
#define MGMTD_TXN_ERR(fmt, ...) \ #define MGMTD_TXN_ERR(fmt, ...) \
zlog_err("%s: ERROR: " fmt, __func__, ##__VA_ARGS__) zlog_err("%s: ERROR: " fmt, __func__, ##__VA_ARGS__)