Skip to content
This repository was archived by the owner on Aug 13, 2025. It is now read-only.

Commit 32189f6

Browse files
committed
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.
1 parent 8ce33dc commit 32189f6

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

bin/delv/delv.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
#define MAXNAME (DNS_NAME_MAXTEXT + 1)
8989

9090
/* Variables used internally by delv. */
91-
char *progname;
91+
char *progname = NULL;
9292
static isc_mem_t *mctx = NULL;
9393
static isc_log_t *lctx = NULL;
9494
static dns_view_t *view = NULL;
@@ -98,6 +98,7 @@ static dns_dispatch_t *dispatch = NULL;
9898
static dns_db_t *roothints = NULL;
9999
static isc_stats_t *resstats = NULL;
100100
static dns_stats_t *resquerystats = NULL;
101+
static FILE *logfp = NULL;
101102

102103
/* Managers */
103104
static isc_nm_t *netmgr = NULL;
@@ -1185,6 +1186,7 @@ plus_option(char *option) {
11851186
if (state) {
11861187
message_trace = state;
11871188
resolve_trace = state;
1189+
logfp = stdout;
11881190
}
11891191
break;
11901192
default:
@@ -1889,7 +1891,6 @@ recvresponse(void *arg) {
18891891
dns_request_t *request = (dns_request_t *)arg;
18901892
dns_message_t *query = dns_request_getarg(request);
18911893
isc_result_t result = dns_request_getresult(request);
1892-
;
18931894
dns_message_t *response = NULL;
18941895

18951896
if (result != ISC_R_SUCCESS) {
@@ -1967,7 +1968,7 @@ recvresponse(void *arg) {
19671968
dns_message_detach(&response);
19681969
dns_request_destroy(&request);
19691970

1970-
view = NULL;
1971+
dns_view_detach(&view);
19711972
shutdown_server();
19721973
}
19731974

@@ -2018,6 +2019,7 @@ sendquery(void *arg) {
20182019
CHECK(dns_requestmgr_create(mctx, dispatchmgr, NULL, NULL,
20192020
&requestmgr));
20202021

2022+
dns_view_attach(view, &(dns_view_t *){ NULL });
20212023
CHECK(dns_request_create(requestmgr, message, NULL, &peer, NULL, NULL,
20222024
DNS_REQUESTOPT_TCP, NULL, 1, 0, 0,
20232025
isc_loop_current(loopmgr), recvresponse,
@@ -2119,6 +2121,8 @@ main(int argc, char *argv[]) {
21192121
isc_loop_t *loop = NULL;
21202122

21212123
progname = argv[0];
2124+
logfp = stderr;
2125+
21222126
preparse_args(argc, argv);
21232127

21242128
argc--;
@@ -2136,7 +2140,7 @@ main(int argc, char *argv[]) {
21362140

21372141
CHECK(setup_style());
21382142

2139-
setup_logging(stderr);
2143+
setup_logging(logfp);
21402144

21412145
if (fulltrace && server != NULL) {
21422146
delv_log(ISC_LOG_WARNING,

bin/delv/delv.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,14 @@ assign values to options like the timeout interval. They have the form
237237
that to look up the requested query name and type. Turning on this
238238
option also activates ``+mtrace`` and ``+rtrace``, so that every
239239
iterative query will be logged, including the full response messages
240-
from each authoritatve server.
240+
from each authoritatve server. These logged messages will be written
241+
to ``stdout`` rather than ``stderr`` as usual, so that the full trace
242+
can be captured more easily.
241243

242244
This is intended to be similar to the behavior of ``dig +trace``, but
243245
because it uses the same code as ``named``, it much more accurately
244246
replicates the behavior of a recursive name server with a cold cache
245-
processing a recursive query.
247+
that is processing a recursive query.
246248

247249
.. option:: +ttl, +nottl
248250

0 commit comments

Comments
 (0)