2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

log dns library warnings to stderr even when not verbose;

do not prefix stderr messages with time stamp
This commit is contained in:
Andreas Gustafsson
2000-05-06 00:48:53 +00:00
parent 5159c42783
commit b4780360a4
2 changed files with 104 additions and 20 deletions

View File

@@ -1276,6 +1276,41 @@ usage() {
exit(0); exit(0);
} }
static void
setup_logging(int level, isc_log_t **logp) {
isc_result_t result;
isc_logdestination_t destination;
isc_logconfig_t *logconfig;
isc_log_t *log = 0;
RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig)
== ISC_R_SUCCESS);
isc_log_setcontext(log);
dns_log_init(log);
dns_log_setcontext(log);
/*
* Set up a channel similar to default_stderr except
* that the logging level is passed in and the
* time is not printed.
*/
destination.file.stream = stderr;
destination.file.name = NULL;
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
result = isc_log_createchannel(logconfig, "stderr",
ISC_LOG_TOFILEDESC,
level,
&destination,
0);
check_result(result, "isc_log_createchannel()");
RUNTIME_CHECK(isc_log_usechannel(logconfig, "stderr",
NULL, NULL) == ISC_R_SUCCESS);
*logp = log;
}
int int
main(int argc, char *argv[]) { main(int argc, char *argv[]) {
int i, ch; int i, ch;
@@ -1288,7 +1323,7 @@ main(int argc, char *argv[]) {
signer_key_t *key; signer_key_t *key;
isc_result_t result; isc_result_t result;
isc_log_t *log = NULL; isc_log_t *log = NULL;
isc_logconfig_t *logconfig; int loglevel;
dns_result_register(); dns_result_register();
@@ -1371,16 +1406,23 @@ main(int argc, char *argv[]) {
cycle = (endtime - starttime) / 4; cycle = (endtime - starttime) / 4;
} }
if (verbose > 0) { switch (verbose) {
RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig) case 0:
== ISC_R_SUCCESS); /*
isc_log_setcontext(log); * We want to see warnings about things like out-of-zone
dns_log_init(log); * data in the master file even when not verbose.
dns_log_setcontext(log); */
RUNTIME_CHECK(isc_log_usechannel(logconfig, "default_stderr", loglevel = ISC_LOG_WARNING;
NULL, NULL) == ISC_R_SUCCESS); break;
case 1:
loglevel = ISC_LOG_INFO;
break;
default:
loglevel = ISC_LOG_DEBUG(verbose - 2 + 1);
break;
} }
setup_logging(loglevel, &log);
argc -= isc_commandline_index; argc -= isc_commandline_index;
argv += isc_commandline_index; argv += isc_commandline_index;

View File

@@ -1276,6 +1276,41 @@ usage() {
exit(0); exit(0);
} }
static void
setup_logging(int level, isc_log_t **logp) {
isc_result_t result;
isc_logdestination_t destination;
isc_logconfig_t *logconfig;
isc_log_t *log = 0;
RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig)
== ISC_R_SUCCESS);
isc_log_setcontext(log);
dns_log_init(log);
dns_log_setcontext(log);
/*
* Set up a channel similar to default_stderr except
* that the logging level is passed in and the
* time is not printed.
*/
destination.file.stream = stderr;
destination.file.name = NULL;
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
result = isc_log_createchannel(logconfig, "stderr",
ISC_LOG_TOFILEDESC,
level,
&destination,
0);
check_result(result, "isc_log_createchannel()");
RUNTIME_CHECK(isc_log_usechannel(logconfig, "stderr",
NULL, NULL) == ISC_R_SUCCESS);
*logp = log;
}
int int
main(int argc, char *argv[]) { main(int argc, char *argv[]) {
int i, ch; int i, ch;
@@ -1288,7 +1323,7 @@ main(int argc, char *argv[]) {
signer_key_t *key; signer_key_t *key;
isc_result_t result; isc_result_t result;
isc_log_t *log = NULL; isc_log_t *log = NULL;
isc_logconfig_t *logconfig; int loglevel;
dns_result_register(); dns_result_register();
@@ -1371,16 +1406,23 @@ main(int argc, char *argv[]) {
cycle = (endtime - starttime) / 4; cycle = (endtime - starttime) / 4;
} }
if (verbose > 0) { switch (verbose) {
RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig) case 0:
== ISC_R_SUCCESS); /*
isc_log_setcontext(log); * We want to see warnings about things like out-of-zone
dns_log_init(log); * data in the master file even when not verbose.
dns_log_setcontext(log); */
RUNTIME_CHECK(isc_log_usechannel(logconfig, "default_stderr", loglevel = ISC_LOG_WARNING;
NULL, NULL) == ISC_R_SUCCESS); break;
case 1:
loglevel = ISC_LOG_INFO;
break;
default:
loglevel = ISC_LOG_DEBUG(verbose - 2 + 1);
break;
} }
setup_logging(loglevel, &log);
argc -= isc_commandline_index; argc -= isc_commandline_index;
argv += isc_commandline_index; argv += isc_commandline_index;