send delv +ns output to stdout

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.
This commit is contained in:
Evan Hunt 2023-02-14 17:28:55 -08:00
parent 8ce33dca6a
commit 32189f6a59
2 changed files with 12 additions and 6 deletions

View 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,

View 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