log debug

This commit is contained in:
Olof Hagsand 2016-07-18 16:14:16 +02:00
parent eaaf1b83e8
commit 8bf95cab31
5 changed files with 84 additions and 17 deletions

View file

@ -646,9 +646,9 @@ from_client_call(clicon_handle h,
struct clicon_msg *msg,
const char *label)
{
int retval = -1;
void *reply_data = NULL;
uint16_t reply_data_len = 0;
int retval = -1;
void *reply_data = NULL;
uint16_t reply_data_len = 0;
struct clicon_msg_call_req *req;
if (clicon_msg_call_decode(msg, &req, label) < 0) {
@ -667,10 +667,17 @@ from_client_call(clicon_handle h,
goto done;
}
retval = send_msg_reply(s,CLICON_MSG_OK, (char *)reply_data, reply_data_len);
free(reply_data);
if ((retval = send_msg_reply(s, CLICON_MSG_OK, (char *)reply_data, reply_data_len)) < 0){
if (errno == ECONNRESET){ /* If cli/netconf dies during plugin downcall */
clicon_log(LOG_WARNING, "client downcall reset");
retval = 0;
}
else
goto done;
}
done:
if (reply_data)
free(reply_data);
return retval;
}

View file

@ -92,14 +92,16 @@ exit_candidate_db(clicon_handle h)
return 0;
}
/*
* cli_debug
* set debug level on stderr (not syslog).
#if 1 /* OBSOLETE */
/*! Set debug level
* The level is either what is specified in arg as int argument.
* _or_ if a 'level' variable is present in vars use that value instead.
* OBSOLETE
*/
int
cli_debug(clicon_handle h, cvec *vars, cg_var *arg)
cli_debug(clicon_handle h,
cvec *vars,
cg_var *arg)
{
cg_var *cv;
int level;
@ -115,7 +117,52 @@ cli_debug(clicon_handle h, cvec *vars, cg_var *arg)
done:
return 0;
}
#endif
/*! Set debug level on CLI client (not backend daemon)
* @param[in] h Clicon handle
* @param[in] vars If variable "level" exists, its integer value is used
* @param[in] arg Else use the integer value of argument
* @note The level is either what is specified in arg as int argument.
* _or_ if a 'level' variable is present in vars use that value instead.
*/
int
cli_debug_cli(clicon_handle h,
cvec *vars,
cg_var *arg)
{
cg_var *cv;
int level;
if ((cv = cvec_find_var(vars, "level")) == NULL)
cv = arg;
level = cv_int32_get(cv);
/* cli */
clicon_debug_init(level, NULL); /* 0: dont debug, 1:debug */
return 0;
}
/*! Set debug level on backend daemon (not CLI)
* @param[in] h Clicon handle
* @param[in] vars If variable "level" exists, its integer value is used
* @param[in] arg Else use the integer value of argument
* @note The level is either what is specified in arg as int argument.
* _or_ if a 'level' variable is present in vars use that value instead.
*/
int
cli_debug_backend(clicon_handle h,
cvec *vars,
cg_var *arg)
{
cg_var *cv;
int level;
if ((cv = cvec_find_var(vars, "level")) == NULL)
cv = arg;
level = cv_int32_get(cv);
/* config daemon */
return clicon_rpc_debug(h, level);
}
void
cli_signal_block(clicon_handle h)

View file

@ -61,7 +61,8 @@ int exit_candidate_db(clicon_handle h);
int cli_set (clicon_handle h, cvec *vars, cg_var *arg);
int cli_merge (clicon_handle h, cvec *vars, cg_var *arg);
int cli_del(clicon_handle h, cvec *vars, cg_var *argv);
int cli_debug(clicon_handle h, cvec *vars, cg_var *argv);
int cli_debug_cli(clicon_handle h, cvec *vars, cg_var *argv);
int cli_debug_backend(clicon_handle h, cvec *vars, cg_var *argv);
int cli_record(clicon_handle h, cvec *vars, cg_var *argv);
int isrecording(void);
int record_command(char *str);