debug option.

git-svn-id: file:///svn/unbound/trunk@813 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2007-12-07 08:29:09 +00:00
parent e297886386
commit a2f143cfcc
5 changed files with 34 additions and 1 deletions

View file

@ -1,3 +1,7 @@
7 December 2007: Wouter
- unbound-host has a -d option to show what happens. This can help
with debugging (why do I get this answer).
6 December 2007: Wouter
- library resolution works in foreground mode, unbound-host app
receives data.

View file

@ -4,6 +4,7 @@ ub_val_ctx_config
ub_val_ctx_add_ta
ub_val_ctx_add_ta_file
ub_val_ctx_trustedkeys
ub_val_ctx_debuglevel
ub_val_ctx_async
ub_val_ctx_poll
ub_val_ctx_wait

View file

@ -221,6 +221,16 @@ ub_val_ctx_trustedkeys(struct ub_val_ctx* ctx, char* fname)
return UB_NOERROR;
}
int
ub_val_ctx_debuglevel(struct ub_val_ctx* ctx, int d)
{
lock_basic_lock(&ctx->cfglock);
verbosity = d;
ctx->env->cfg->verbosity = d;
lock_basic_unlock(&ctx->cfglock);
return UB_NOERROR;
}
int
ub_val_ctx_async(struct ub_val_ctx* ctx, int dothread)
{

View file

@ -239,6 +239,16 @@ int ub_val_ctx_add_ta_file(struct ub_val_ctx* ctx, char* fname);
*/
int ub_val_ctx_trustedkeys(struct ub_val_ctx* ctx, char* fname);
/**
* Set debug verbosity for the context
* Output is directed to stderr.
* @param ctx: context.
* @param d: debug level, 0 is off, 1 is very minimal, 2 is detailed,
* and 3 is lots.
* @return 0 if OK, else error.
*/
int ub_val_ctx_debuglevel(struct ub_val_ctx* ctx, int d);
/**
* Set a context behaviour for asynchronous action.
* @param ctx: context.

View file

@ -64,6 +64,7 @@ usage()
printf(" -f keyfile read trust anchors from file, with lines as -y.\n");
printf(" -F keyfile read named.conf-style trust anchors.\n");
printf(" -v be more verbose, shows nodata and security.\n");
printf(" -d debug, traces the action, -d -d shows more.\n");
printf(" -h show this usage help.\n");
printf("Version %s\n", PACKAGE_VERSION);
printf("BSD licensed, see LICENSE in source package for details.\n");
@ -375,6 +376,7 @@ int main(int argc, char* argv[])
char* qclass = NULL;
char* qtype = NULL;
struct ub_val_ctx* ctx = NULL;
int debuglevel = 0;
ctx = ub_val_ctx_create();
if(!ctx) {
@ -383,11 +385,17 @@ int main(int argc, char* argv[])
}
/* parse the options */
while( (c=getopt(argc, argv, "F:c:f:ht:vy:")) != -1) {
while( (c=getopt(argc, argv, "F:c:df:ht:vy:")) != -1) {
switch(c) {
case 'c':
qclass = optarg;
break;
case 'd':
debuglevel++;
if(debuglevel < 2)
debuglevel = 2; /* at least VERB_DETAIL */
ub_val_ctx_debuglevel(ctx, debuglevel);
break;
case 't':
qtype = optarg;
break;