]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
send delv +ns output to stdout
authorEvan Hunt <each@isc.org>
Wed, 15 Feb 2023 01:28:55 +0000 (17:28 -0800)
committerEvan Hunt <each@isc.org>
Tue, 28 Mar 2023 19:39:06 +0000 (12:39 -0700)
normally, the only output of delv that is sent to stdout is
the final answer to the query; all other output is sent to
stderr. this seems undesirable for delv +ns, which will
only be used to see the process of finding the answer. so,
for that case, we now send all the logging to stdout.

bin/delv/delv.c
bin/delv/delv.rst

index 485b193d117f23f87ffc88cb5788d070dba2ac5e..ad747368d5131d830a594284e2bfdefc49545b2f 100644 (file)
@@ -88,7 +88,7 @@
 #define MAXNAME (DNS_NAME_MAXTEXT + 1)
 
 /* Variables used internally by delv. */
-char *progname;
+char *progname = NULL;
 static isc_mem_t *mctx = NULL;
 static isc_log_t *lctx = NULL;
 static dns_view_t *view = NULL;
@@ -98,6 +98,7 @@ static dns_dispatch_t *dispatch = NULL;
 static dns_db_t *roothints = NULL;
 static isc_stats_t *resstats = NULL;
 static dns_stats_t *resquerystats = NULL;
+static FILE *logfp = NULL;
 
 /* Managers */
 static isc_nm_t *netmgr = NULL;
@@ -1185,6 +1186,7 @@ plus_option(char *option) {
                        if (state) {
                                message_trace = state;
                                resolve_trace = state;
+                               logfp = stdout;
                        }
                        break;
                default:
@@ -1889,7 +1891,6 @@ recvresponse(void *arg) {
        dns_request_t *request = (dns_request_t *)arg;
        dns_message_t *query = dns_request_getarg(request);
        isc_result_t result = dns_request_getresult(request);
-       ;
        dns_message_t *response = NULL;
 
        if (result != ISC_R_SUCCESS) {
@@ -1967,7 +1968,7 @@ cleanup:
        dns_message_detach(&response);
        dns_request_destroy(&request);
 
-       view = NULL;
+       dns_view_detach(&view);
        shutdown_server();
 }
 
@@ -2018,6 +2019,7 @@ sendquery(void *arg) {
        CHECK(dns_requestmgr_create(mctx, dispatchmgr, NULL, NULL,
                                    &requestmgr));
 
+       dns_view_attach(view, &(dns_view_t *){ NULL });
        CHECK(dns_request_create(requestmgr, message, NULL, &peer, NULL, NULL,
                                 DNS_REQUESTOPT_TCP, NULL, 1, 0, 0,
                                 isc_loop_current(loopmgr), recvresponse,
@@ -2119,6 +2121,8 @@ main(int argc, char *argv[]) {
        isc_loop_t *loop = NULL;
 
        progname = argv[0];
+       logfp = stderr;
+
        preparse_args(argc, argv);
 
        argc--;
@@ -2136,7 +2140,7 @@ main(int argc, char *argv[]) {
 
        CHECK(setup_style());
 
-       setup_logging(stderr);
+       setup_logging(logfp);
 
        if (fulltrace && server != NULL) {
                delv_log(ISC_LOG_WARNING,
index 8b52f9f858f9b7a480084d8aebcc481669a79a5a..5d91fe75fb4a97fec862e56d089ee095ae5451b6 100644 (file)
@@ -237,12 +237,14 @@ assign values to options like the timeout interval. They have the form
    that to look up the requested query name and type. Turning on this
    option also activates ``+mtrace`` and ``+rtrace``, so that every
    iterative query will be logged, including the full response messages
-   from each authoritatve server.
+   from each authoritatve server.  These logged messages will be written
+   to ``stdout`` rather than ``stderr`` as usual, so that the full trace
+   can be captured more easily.
 
    This is intended to be similar to the behavior of ``dig +trace``, but
    because it uses the same code as ``named``, it much more accurately
    replicates the behavior of a recursive name server with a cold cache
-   processing a recursive query.
+   that is processing a recursive query.
 
 .. option:: +ttl, +nottl