log debug
This commit is contained in:
parent
eaaf1b83e8
commit
8bf95cab31
5 changed files with 84 additions and 17 deletions
|
|
@ -646,9 +646,9 @@ from_client_call(clicon_handle h,
|
||||||
struct clicon_msg *msg,
|
struct clicon_msg *msg,
|
||||||
const char *label)
|
const char *label)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
void *reply_data = NULL;
|
void *reply_data = NULL;
|
||||||
uint16_t reply_data_len = 0;
|
uint16_t reply_data_len = 0;
|
||||||
struct clicon_msg_call_req *req;
|
struct clicon_msg_call_req *req;
|
||||||
|
|
||||||
if (clicon_msg_call_decode(msg, &req, label) < 0) {
|
if (clicon_msg_call_decode(msg, &req, label) < 0) {
|
||||||
|
|
@ -667,10 +667,17 @@ from_client_call(clicon_handle h,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = send_msg_reply(s,CLICON_MSG_OK, (char *)reply_data, reply_data_len);
|
if ((retval = send_msg_reply(s, CLICON_MSG_OK, (char *)reply_data, reply_data_len)) < 0){
|
||||||
free(reply_data);
|
if (errno == ECONNRESET){ /* If cli/netconf dies during plugin downcall */
|
||||||
|
clicon_log(LOG_WARNING, "client downcall reset");
|
||||||
|
retval = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
done:
|
done:
|
||||||
|
if (reply_data)
|
||||||
|
free(reply_data);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,14 +92,16 @@ exit_candidate_db(clicon_handle h)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
#if 1 /* OBSOLETE */
|
||||||
* cli_debug
|
/*! Set debug level
|
||||||
* set debug level on stderr (not syslog).
|
|
||||||
* The level is either what is specified in arg as int argument.
|
* 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.
|
* _or_ if a 'level' variable is present in vars use that value instead.
|
||||||
|
* OBSOLETE
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
cli_debug(clicon_handle h, cvec *vars, cg_var *arg)
|
cli_debug(clicon_handle h,
|
||||||
|
cvec *vars,
|
||||||
|
cg_var *arg)
|
||||||
{
|
{
|
||||||
cg_var *cv;
|
cg_var *cv;
|
||||||
int level;
|
int level;
|
||||||
|
|
@ -115,7 +117,52 @@ cli_debug(clicon_handle h, cvec *vars, cg_var *arg)
|
||||||
done:
|
done:
|
||||||
return 0;
|
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
|
void
|
||||||
cli_signal_block(clicon_handle h)
|
cli_signal_block(clicon_handle h)
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,8 @@ int exit_candidate_db(clicon_handle h);
|
||||||
int cli_set (clicon_handle h, cvec *vars, cg_var *arg);
|
int cli_set (clicon_handle h, cvec *vars, cg_var *arg);
|
||||||
int cli_merge (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_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 cli_record(clicon_handle h, cvec *vars, cg_var *argv);
|
||||||
int isrecording(void);
|
int isrecording(void);
|
||||||
int record_command(char *str);
|
int record_command(char *str);
|
||||||
|
|
|
||||||
|
|
@ -138,10 +138,11 @@ slogtime(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! Make a logging call to syslog.
|
/*! Make a logging call to syslog (or stderr).
|
||||||
*
|
*
|
||||||
* This is the _only_ place the actual syslog (or stderr) logging is made in clicon,..
|
* This is the _only_ place the actual syslog (or stderr) logging is made in clicon,..
|
||||||
* See also clicon_log()
|
* @note yslog makes itw own filtering, but if log to stderr we do it here
|
||||||
|
* @see clicon_debug()
|
||||||
*
|
*
|
||||||
* @param[in] level log level, eg LOG_DEBUG,LOG_INFO,...,LOG_EMERG. Thisis OR:d with facility == LOG_USER
|
* @param[in] level log level, eg LOG_DEBUG,LOG_INFO,...,LOG_EMERG. Thisis OR:d with facility == LOG_USER
|
||||||
* @param[in] msg Message to print as argv.
|
* @param[in] msg Message to print as argv.
|
||||||
|
|
@ -152,6 +153,11 @@ clicon_log_str(int level,
|
||||||
{
|
{
|
||||||
if (_logflags & CLICON_LOG_SYSLOG)
|
if (_logflags & CLICON_LOG_SYSLOG)
|
||||||
syslog(LOG_MAKEPRI(LOG_USER, level), "%s", msg);
|
syslog(LOG_MAKEPRI(LOG_USER, level), "%s", msg);
|
||||||
|
/* syslog makes own filtering, we do it here:
|
||||||
|
* if normal (not debug) then filter loglevels >= debug
|
||||||
|
*/
|
||||||
|
if (debug == 0 && level >= LOG_DEBUG)
|
||||||
|
goto done;
|
||||||
if (_logflags & CLICON_LOG_STDERR){
|
if (_logflags & CLICON_LOG_STDERR){
|
||||||
flogtime(stderr);
|
flogtime(stderr);
|
||||||
fprintf(stderr, "%s\n", msg);
|
fprintf(stderr, "%s\n", msg);
|
||||||
|
|
@ -184,6 +190,7 @@ clicon_log_str(int level,
|
||||||
}
|
}
|
||||||
cb--;
|
cb--;
|
||||||
}
|
}
|
||||||
|
done:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -388,10 +388,15 @@ downcall(clicon_handle h, uint16_t op, uint16_t len, void *arg,
|
||||||
* unchunk_group(label) to deallocate
|
* unchunk_group(label) to deallocate
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
clicon_rpc_call(clicon_handle h, uint16_t op, char *plugin, char *func,
|
clicon_rpc_call(clicon_handle h,
|
||||||
void *param, uint16_t paramlen,
|
uint16_t op,
|
||||||
char **ret, uint16_t *retlen,
|
char *plugin,
|
||||||
const void *label)
|
char *func,
|
||||||
|
void *param,
|
||||||
|
uint16_t paramlen,
|
||||||
|
char **ret,
|
||||||
|
uint16_t *retlen,
|
||||||
|
const void *label)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
struct clicon_msg *msg;
|
struct clicon_msg *msg;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue