mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 06:55:30 +00:00
test isc_log_write1() and isc_log_setduplicateinterval()
usage message if command line errors.
This commit is contained in:
@@ -15,13 +15,14 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: log_test.c,v 1.3 1999/10/06 20:07:24 tale Exp $ */
|
/* $Id: log_test.c,v 1.4 1999/10/25 19:55:49 tale Exp $ */
|
||||||
|
|
||||||
/* Principal Authors: DCL */
|
/* Principal Authors: DCL */
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <isc/commandline.h>
|
#include <isc/commandline.h>
|
||||||
#include <isc/mem.h>
|
#include <isc/mem.h>
|
||||||
@@ -35,6 +36,8 @@
|
|||||||
#define SYSLOG_FILE "/var/log/daemon.log"
|
#define SYSLOG_FILE "/var/log/daemon.log"
|
||||||
#define FILE_VERSIONS 10
|
#define FILE_VERSIONS 10
|
||||||
|
|
||||||
|
char usage[] = "Usage: %s [-m] [-s syslog_logfile] [-r file_versions]\n";
|
||||||
|
|
||||||
#define CHECK_ISC(expr) result = expr; \
|
#define CHECK_ISC(expr) result = expr; \
|
||||||
if (result != ISC_R_SUCCESS) { \
|
if (result != ISC_R_SUCCESS) { \
|
||||||
fprintf(stderr, "%s: " #expr "%s: exiting\n", \
|
fprintf(stderr, "%s: " #expr "%s: exiting\n", \
|
||||||
@@ -50,7 +53,7 @@
|
|||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv) {
|
main (int argc, char **argv) {
|
||||||
char *progname, *syslog_file;
|
char *progname, *syslog_file, *message;
|
||||||
int ch, i, file_versions;
|
int ch, i, file_versions;
|
||||||
isc_boolean_t show_final_mem = ISC_FALSE;
|
isc_boolean_t show_final_mem = ISC_FALSE;
|
||||||
isc_log_t *lctx;
|
isc_log_t *lctx;
|
||||||
@@ -88,14 +91,21 @@ main (int argc, char **argv) {
|
|||||||
ISC_LOG_ROLLINFINITE);
|
ISC_LOG_ROLLINFINITE);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
case '?':
|
||||||
|
fprintf(stderr, usage, progname);
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
argc -= isc_commandline_index;
|
argc -= isc_commandline_index;
|
||||||
argv += isc_commandline_index;
|
argv += isc_commandline_index;
|
||||||
|
|
||||||
|
if (argc > 0) {
|
||||||
|
fprintf(stderr, usage, progname);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(stderr, "==> stderr begin\n");
|
fprintf(stderr, "==> stderr begin\n");
|
||||||
isc_log_opensyslog(progname, LOG_PID, LOG_DAEMON);
|
isc_log_opensyslog(progname, LOG_PID, LOG_DAEMON);
|
||||||
|
|
||||||
@@ -248,6 +258,26 @@ main (int argc, char **argv) {
|
|||||||
ISC_LOG_DEBUG(5),
|
ISC_LOG_DEBUG(5),
|
||||||
"This debug level is too high and should not appear!");
|
"This debug level is too high and should not appear!");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test out the duplicate filtering using the debug_test channel.
|
||||||
|
*/
|
||||||
|
isc_log_setduplicateinterval(lctx, 10);
|
||||||
|
message = "This message should appear only once on stderr";
|
||||||
|
|
||||||
|
isc_log_write1(lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_RBTDB,
|
||||||
|
ISC_LOG_CRITICAL, message);
|
||||||
|
isc_log_write1(lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_RBTDB,
|
||||||
|
ISC_LOG_CRITICAL, message);
|
||||||
|
|
||||||
|
isc_log_setduplicateinterval(lctx, 1);
|
||||||
|
message = "This message should appear twice on stderr";
|
||||||
|
|
||||||
|
isc_log_write1(lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_RBTDB,
|
||||||
|
ISC_LOG_CRITICAL, message);
|
||||||
|
sleep(2);
|
||||||
|
isc_log_write1(lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_RBTDB,
|
||||||
|
ISC_LOG_CRITICAL, message);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Review where everything went.
|
* Review where everything went.
|
||||||
* XXXDCL NT
|
* XXXDCL NT
|
||||||
|
Reference in New Issue
Block a user