Skip to content

Commit

Permalink
Fixed Debug -D msg: dont show length in detailed debug
Browse files Browse the repository at this point in the history
  • Loading branch information
olofhagsand committed Nov 27, 2024
1 parent 4c57edf commit be5a7c4
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion apps/backend/backend_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ from_client_edit_config(clixon_handle h,
}
/* Clixon extension: copy */
if ((attr = xml_find_value(xn, "copystartup")) != NULL &&
strcmp(attr,"true") == 0){
strcmp(attr, "true") == 0){
if (xmldb_copy(h, "running", "startup") < 0){
if (netconf_operation_failed(cbret, "application", clixon_err_reason())< 0)
goto done;
Expand Down
2 changes: 1 addition & 1 deletion apps/netconf/netconf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ netconf_input_cb(int s,
cbmsg = NULL;
break;
}
if (clixon_debug_isset(CLIXON_DBG_DETAIL))
if (clixon_debug_detail())
clixon_debug(CLIXON_DBG_MSG | CLIXON_DBG_DETAIL, "Recv ext: %s", cbuf_get(cbmsg));
else
clixon_debug(CLIXON_DBG_MSG, "Recv ext len: %lu", cbuf_len(cbmsg));
Expand Down
25 changes: 17 additions & 8 deletions lib/clixon/clixon_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,25 @@ int clixon_debug_init(clixon_handle h, int dbglevel);
int clixon_debug_get(void);
int clixon_debug_fn(clixon_handle h, const char *fn, const int line, int dbglevel, cxobj *x, const char *format, ...) __attribute__ ((format (printf, 6, 7)));

/* Is subject set ? */
static inline int clixon_debug_isset(unsigned n)
{
unsigned level = clixon_debug_get();
unsigned detail = (n & CLIXON_DBG_DMASK) >> CLIXON_DBG_DSHIFT;
unsigned subject = (n & CLIXON_DBG_SMASK);

/* not this subject */
if ((level & subject) == 0)
return 0;
return ((level & CLIXON_DBG_DMASK) >= detail);
unsigned level = clixon_debug_get();
unsigned detail = (n & CLIXON_DBG_DMASK) >> CLIXON_DBG_DSHIFT;
unsigned subject = (n & CLIXON_DBG_SMASK);

/* not this subject */
if ((level & subject) == 0)
return 0;
return ((level & CLIXON_DBG_DMASK) >= detail);
}

/* Is detail set ?, return detail level 0-7 */
static inline int clixon_debug_detail()
{
unsigned level = clixon_debug_get();

return (level & CLIXON_DBG_DMASK) >> CLIXON_DBG_DSHIFT;
}

#endif /* _CLIXON_DEBUG_H_ */
2 changes: 1 addition & 1 deletion lib/src/clixon_netconf_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -2203,7 +2203,7 @@ netconf_output(int s,
char *buf = cbuf_get(cb);
int len = cbuf_len(cb);

if (clixon_debug_isset(CLIXON_DBG_DETAIL))
if (clixon_debug_detail())
clixon_debug(CLIXON_DBG_MSG | CLIXON_DBG_DETAIL, "Send ext: %s", cbuf_get(cb));
else
clixon_debug(CLIXON_DBG_MSG, "Send ext len: %lu", cbuf_len(cb));
Expand Down
12 changes: 6 additions & 6 deletions lib/src/clixon_proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,13 @@ clixon_msg_send(int s,
int retval = -1;

if (descr){
if (clixon_debug_isset(CLIXON_DBG_DETAIL))
if (clixon_debug_detail())
clixon_debug(CLIXON_DBG_MSG | CLIXON_DBG_DETAIL, "Send [%s] %s", descr, cbuf_get(cb));
else
clixon_debug(CLIXON_DBG_MSG, "Send [%s] len: %lu", descr, cbuf_len(cb));
}
else{
if (clixon_debug_isset(CLIXON_DBG_DETAIL))
if (clixon_debug_detail())
clixon_debug(CLIXON_DBG_MSG | CLIXON_DBG_DETAIL, "Send %s", cbuf_get(cb));
else
clixon_debug(CLIXON_DBG_MSG, "Send len: %lu", cbuf_len(cb));
Expand Down Expand Up @@ -437,13 +437,13 @@ clixon_msg_rcv10(int s,
}
else {
if (descr){
if (clixon_debug_isset(CLIXON_DBG_DETAIL))
if (clixon_debug_detail())
clixon_debug(CLIXON_DBG_MSG | CLIXON_DBG_DETAIL, "Recv [%s]: %s", descr, cbuf_get(cb));
else
clixon_debug(CLIXON_DBG_MSG, "Recv [%s] len: %lu", descr, cbuf_len(cb));
}
else{
if (clixon_debug_isset(CLIXON_DBG_DETAIL))
if (clixon_debug_detail())
clixon_debug(CLIXON_DBG_MSG | CLIXON_DBG_DETAIL, "Recv: %s", cbuf_get(cb));
else
clixon_debug(CLIXON_DBG_MSG, "Recv len: %lu", cbuf_len(cb));
Expand Down Expand Up @@ -620,13 +620,13 @@ clixon_msg_rcv11(int s,
}
else {
if (descr){
if (clixon_debug_isset(CLIXON_DBG_DETAIL))
if (clixon_debug_detail())
clixon_debug(CLIXON_DBG_MSG | CLIXON_DBG_DETAIL, "Recv [%s]: %s", descr, cbuf_get(cbmsg));
else
clixon_debug(CLIXON_DBG_MSG, "Recv [%s] len: %lu", descr, cbuf_len(cbmsg));
}
else{
if (clixon_debug_isset(CLIXON_DBG_DETAIL))
if (clixon_debug_detail())
clixon_debug(CLIXON_DBG_MSG | CLIXON_DBG_DETAIL, "Recv: %s", cbuf_get(cbmsg));
else
clixon_debug(CLIXON_DBG_MSG, "Recv len: %lu", cbuf_len(cbmsg));
Expand Down

0 comments on commit be5a7c4

Please sign in to comment.