mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-18 02:39:44 +00:00
Fix the DEBUG_cli_parsed() macro
Was logging a blank line instead of "parsed `key`=`value`..."
This commit is contained in:
parent
c3a94a7ac3
commit
fc47bc541f
8
cli.c
8
cli.c
@ -312,7 +312,11 @@ int cli_parse(const int argc, const char *const *args, const struct cli_schema *
|
||||
|
||||
void _debug_cli_parsed(struct __sourceloc __whence, const char *tag, const struct cli_parsed *parsed)
|
||||
{
|
||||
_DEBUG_argv(tag, parsed->argc, parsed->args);
|
||||
strbuf t = strbuf_alloca(strlen(tag) + 3);
|
||||
strbuf_putc(t, '{');
|
||||
strbuf_puts(t, tag);
|
||||
strbuf_putc(t, '}');
|
||||
_DEBUG_argv(strbuf_str(t), parsed->argc, parsed->args);
|
||||
strbuf b = strbuf_alloca(1024);
|
||||
unsigned i;
|
||||
for (i = 0; i < parsed->labelc; ++i) {
|
||||
@ -321,7 +325,7 @@ void _debug_cli_parsed(struct __sourceloc __whence, const char *tag, const struc
|
||||
}
|
||||
if (parsed->varargi >= 0)
|
||||
strbuf_sprintf(b, " varargi=%d", parsed->varargi);
|
||||
_DEBUGF(tag, "parsed%s", strbuf_str(b));
|
||||
_DEBUGF_TAG(tag, "parsed%s", strbuf_str(b));
|
||||
}
|
||||
|
||||
int cli_invoke(const struct cli_parsed *parsed, struct cli_context *context)
|
||||
|
2
cli.h
2
cli.h
@ -74,7 +74,7 @@ struct cli_parsed {
|
||||
|
||||
void _debug_cli_parsed(struct __sourceloc __whence, const char *tag, const struct cli_parsed *parsed);
|
||||
|
||||
#define DEBUG_cli_parsed(FLAG,parsed) do { if (IF_DEBUG(FLAG)) _debug_cli_parsed(__WHENCE__, "{" #FLAG "}", parsed); } while (0)
|
||||
#define DEBUG_cli_parsed(FLAG,parsed) do { if (IF_DEBUG(FLAG)) _debug_cli_parsed(__WHENCE__, #FLAG, parsed); } while (0)
|
||||
|
||||
int cli_usage(const struct cli_schema *commands, const struct cli_schema *end_commands, XPRINTF xpf);
|
||||
int cli_usage_args(const int argc, const char *const *args, const struct cli_schema *commands, const struct cli_schema *end_commands, XPRINTF xpf);
|
||||
|
2
debug.h
2
debug.h
@ -41,7 +41,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#define DEBUG(FLAG,X) DEBUGF(FLAG, "%s", (X))
|
||||
#define DEBUGF_perror(FLAG,F,...) do { if (IF_DEBUG(FLAG)) _DEBUGF_TAG_perror(#FLAG, F, ##__VA_ARGS__); } while (0)
|
||||
#define DEBUG_perror(FLAG,X) DEBUGF_perror(FLAG, "%s", (X))
|
||||
#define DEBUG_argv(FLAG,X,ARGC,ARGV) do { if (IF_DEBUG(FLAG)) _DEBUG_TAG_argv(#FLAG, X, (ARGC), (ARGV)); } while (0)
|
||||
#define DEBUG_argv(FLAG,X,ARGC,ARGV) do { if (IF_DEBUG(FLAG)) _DEBUGF_TAG_argv(#FLAG, X, (ARGC), (ARGV)); } while (0)
|
||||
|
||||
#define D(FLAG) DEBUG(FLAG, "D")
|
||||
#define T DEBUG(trace, "T")
|
||||
|
2
log.h
2
log.h
@ -122,7 +122,7 @@ __SERVAL_LOG_INLINE int logErrorAndReturnNegativeOne(struct __sourceloc whence,
|
||||
|
||||
#define _DEBUGF_TAG(TAG,F,...) _DEBUGF("{%s} " F, (TAG), ##__VA_ARGS__)
|
||||
#define _DEBUGF_TAG_perror(TAG,F,...) _DEBUGF_perror("{%s} " F, (TAG), ##__VA_ARGS__)
|
||||
#define _DEBUGF_TAG_argv(TAG,X,ARGC,ARGV) _DEBUGF_argv("{" TAG "} " X, (ARGC), (ARGV))
|
||||
#define _DEBUG_TAG_argv(TAG,X,ARGC,ARGV) _DEBUG_argv("{" TAG "} " X, (ARGC), (ARGV))
|
||||
|
||||
#define dump(X,A,N) logDump(LOG_LEVEL_DEBUG, __WHENCE__, (X), (const unsigned char *)(A), (size_t)(N))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user