log_test.c revision ca41b452ede6feaa9d8739ec3cae19389a7b0d03
/*
* Copyright (C) 1999, 2000 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
/* $Id: log_test.c,v 1.7 2000/02/03 23:03:46 halley Exp $ */
/* Principal Authors: DCL */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <isc/commandline.h>
#define SYSLOG_FILE "/var/log/daemon.log"
#define FILE_VERSIONS 10
char usage[] = "Usage: %s [-m] [-s syslog_logfile] [-r file_versions]\n";
if (result != ISC_R_SUCCESS) { \
}
if (result != DNS_R_SUCCESS) { \
}
int
int ch, i, file_versions;
progname++;
else
switch (ch) {
case 'm':
break;
case 's':
break;
case 'r':
if (file_versions < 0 &&
"%d (ISC_LOG_ROLLNEVER), "
"%d (ISC_LOG_ROLLINFINITE) "
"or > 0\n", progname,
exit(1);
}
break;
case '?':
exit(1);
}
}
if (argc > 0) {
exit(1);
}
/*
* Create a file channel to test file opening, size limiting and
* version rolling.
*/
/*
* Create a dynamic debugging channel to a file descriptor.
*/
/*
* Test the usability of the four predefined logging channels.
*/
NULL));
/*
* Use the custom channels.
*/
/*
* Write to the internal default by testing both a category for which
* no channel has been specified and a category which was specified
* but not with the named module.
*/
ISC_LOG_CRITICAL, "%s",
"Unspecified category and unspecified module to stderr");
ISC_LOG_CRITICAL, "%s",
"Specified category and unspecified module to stderr");
/*
* Write to default_syslog, default_stderr and default_debug.
*/
ISC_LOG_WARNING, "%s%s",
"Using the predefined channels to send ",
"to syslog+stderr+stderr");
/*
* Write to predefined null channel.
*/
ISC_LOG_INFO, "This is to null and should not appear!");
/*
* Reset the internal default to use syslog instead of stderr,
* and test it.
*/
NULL));
ISC_LOG_ERROR, "%s%s",
"This message to the redefined default category should ",
"be second in syslog");
/*
* Write to the file channel.
*/
if (file_versions == ISC_LOG_ROLLINFINITE)
else
"This should be rolled over "
"and not appear!");
for (i = file_versions - 1; i >= 0; i--)
"This should be in file %d/%d", i,
file_versions - 1);
"This should be in the base file");
} else {
for (i = 1; i <= file_versions; i++)
"This is message %d in the log file", i);
}
/*
* Write a debugging message to a category that has no
* debugging channels for the named module.
*/
ISC_LOG_DEBUG(1),
"This debug message should not appear!");
/*
* Write debugging messages to a dynamic debugging channel.
*/
ISC_LOG_DEBUG(5),
"This debug level is too high and should not appear!");
/*
* Test out the duplicate filtering using the debug_test channel.
*/
message = "This message should appear only once on stderr";
message = "This message should appear twice on stderr";
sleep(2);
/*
* Review where everything went.
* XXXDCL NT
*/
system("tail -2");
if (show_final_mem)
exit(0);
}