330. [func] New function isc_log_wouldlog().
(note: #330 is out of place in CHANGES, because it's new in rc4, but if
it was in the place that 330 is supposed to go, no one would see it. So,
leave it at the top)
+ 330. [func] New function isc_log_wouldlog().
+
402. [bug] Treat undefined acls as errors, rather than
warning and then later throwing an assertion.
[RT #252]
* SOFTWARE.
*/
-/* $Id: client.c,v 1.98.2.3 2000/07/26 23:51:31 bwelling Exp $ */
+/* $Id: client.c,v 1.98.2.4 2000/08/22 01:45:08 bwelling Exp $ */
#include <config.h>
if (result != ISC_R_SUCCESS) {
ns_client_log(client, NS_LOGCATEGORY_CLIENT,
NS_LOGMODULE_CLIENT, ISC_LOG_ERROR,
- "setting timouet: %s",
+ "setting timeout: %s",
isc_result_totext(result));
/* Continue anyway. */
}
{
va_list ap;
+ if (isc_log_wouldlog(ns_g_lctx, level) == ISC_FALSE)
+ return;
+
va_start(ap, fmt);
ns_client_logv(client, category, module, level, fmt, ap);
va_end(ap);
* SOFTWARE.
*/
-/* $Id: query.c,v 1.109.2.10 2000/08/08 19:30:13 bwelling Exp $ */
+/* $Id: query.c,v 1.109.2.11 2000/08/22 01:45:09 bwelling Exp $ */
#include <config.h>
char text[256];
isc_region_t r;
dns_rdataset_t *rdataset;
+ int level = ISC_LOG_DEBUG(1);
+
+ if (! isc_log_wouldlog(ns_g_lctx, level))
+ return;
/* XXXRTH Allow this to be turned off! */
}
isc_buffer_usedregion(&b, &r);
ns_client_log(client, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_QUERY,
- ISC_LOG_DEBUG(1), "query: %s%.*s", namebuf,
+ level, "query: %s%.*s", namebuf,
(int)r.length, (char *)r.base);
}
* SOFTWARE.
*/
-/* $Id: xfrout.c,v 1.68.2.1 2000/08/07 22:04:31 gson Exp $ */
+/* $Id: xfrout.c,v 1.68.2.2 2000/08/22 01:45:11 bwelling Exp $ */
#include <config.h>
break;
}
- log_rr(name, rdata, ttl); /* XXX */
+ if (isc_log_wouldlog(ns_g_lctx, XFROUT_RR_LOGLEVEL))
+ log_rr(name, rdata, ttl); /* XXX */
dns_message_gettempname(msg, &msgname);
dns_name_init(msgname, NULL);
* SOFTWARE.
*/
-/* $Id: dispatch.c,v 1.57 2000/06/22 21:54:23 tale Exp $ */
+/* $Id: dispatch.c,v 1.57.2.1 2000/08/22 01:45:14 bwelling Exp $ */
#include <config.h>
char msgbuf[2048];
va_list ap;
+ if (! isc_log_wouldlog(dns_lctx, level))
+ return;
+
va_start(ap, fmt);
vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap);
va_end(ap);
char msgbuf[2048];
va_list ap;
+ if (! isc_log_wouldlog(dns_lctx, level))
+ return;
+
va_start(ap, fmt);
vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap);
va_end(ap);
char peerbuf[256];
va_list ap;
+ if (! isc_log_wouldlog(dns_lctx, level))
+ return;
+
va_start(ap, fmt);
vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap);
va_end(ap);
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: validator.c,v 1.63.2.3 2000/07/27 22:50:02 gson Exp $ */
+/* $Id: validator.c,v 1.63.2.4 2000/08/22 01:45:16 bwelling Exp $ */
#include <config.h>
{
va_list ap;
+ if (! isc_log_wouldlog(dns_lctx, level))
+ return;
+
va_start(ap, fmt);
validator_logv(val, DNS_LOGCATEGORY_DNSSEC,
DNS_LOGMODULE_VALIDATOR, level, fmt, ap);
* SOFTWARE.
*/
-/* $Id: xfrin.c,v 1.79.2.4 2000/07/27 22:56:38 gson Exp $ */
+/* $Id: xfrin.c,v 1.79.2.5 2000/08/22 01:45:18 bwelling Exp $ */
#include <config.h>
{
va_list ap;
+ if (isc_log_wouldlog(dns_lctx, level) == ISC_FALSE)
+ return;
+
va_start(ap, fmt);
xfrin_logv(level, zonename, masteraddr, fmt, ap);
va_end(ap);
{
va_list ap;
+ if (isc_log_wouldlog(dns_lctx, level) == ISC_FALSE)
+ return;
+
va_start(ap, fmt);
xfrin_logv(level, &xfr->name, &xfr->masteraddr, fmt, ap);
va_end(ap);
* SOFTWARE.
*/
-/* $Id: zone.c,v 1.152.2.6 2000/08/21 20:51:47 bwelling Exp $ */
+/* $Id: zone.c,v 1.152.2.7 2000/08/22 01:45:20 bwelling Exp $ */
#include <config.h>
int len;
isc_result_t result = ISC_R_FAILURE;
+ if (isc_log_wouldlog(dns_lctx, level) == ISC_FALSE)
+ return;
+
isc_buffer_init(&buffer, namebuf, sizeof(namebuf));
if (dns_name_dynamic(&zone->origin))
* SOFTWARE.
*/
-/* $Id: log.h,v 1.25 2000/06/19 21:45:03 explorer Exp $ */
+/* $Id: log.h,v 1.25.2.1 2000/08/22 01:45:26 bwelling Exp $ */
#ifndef ISC_LOG_H
#define ISC_LOG_H 1
* The current logging debugging level is returned.
*/
+isc_boolean_t
+isc_log_wouldlog(isc_log_t *lctx, int level);
+/*
+ * Determine whether logging something to 'lctx' at 'level' would
+ * actually cause something to be logged somewhere.
+ *
+ * If ISC_FALSE is returned, it is guaranteed that nothing would
+ * be logged, allowing the caller to omit unnecessary
+ * isc_log_write() calls and possible message preformatting.
+ */
+
void
isc_log_setduplicateinterval(isc_logconfig_t *lcfg, unsigned int interval);
/*
* SOFTWARE.
*/
-/* $Id: log.c,v 1.38 2000/06/23 17:52:20 tale Exp $ */
+/* $Id: log.c,v 1.38.2.1 2000/08/22 01:45:24 bwelling Exp $ */
/* Principal Authors: DCL */
return (ISC_R_SUCCESS);
}
+isc_boolean_t
+isc_log_wouldlog(isc_log_t *lctx, int level) {
+ /*
+ * Try to avoid locking the mutex for messages which can't
+ * possibly be logged to any channels -- primarily debugging
+ * messages that the debug level is not high enough to print.
+ *
+ * If the level is (mathematically) less than or equal to the
+ * highest_level, or if there is a dynamic channel and the level is
+ * less than or equal to the debug level, the main loop must be
+ * entered to see if the message should really be output.
+ *
+ * NOTE: this is UNLOCKED access to the logconfig. However,
+ * the worst thing that can happen is that a bad decision is made
+ * about returning without logging, and that's not a big concern,
+ * because that's a risk anyway if the logconfig is being
+ * dynamically changed.
+ */
+
+ if (lctx == NULL)
+ return (ISC_FALSE);
+
+ return (ISC_TF(level <= lctx->logconfig->highest_level ||
+ (lctx->logconfig->dynamic &&
+ level <= lctx->debug_level)));
+}
+
static void
isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
isc_logmodule_t *module, int level, isc_boolean_t write_once,
REQUIRE(category->id < lctx->category_count);
REQUIRE(module->id < lctx->module_count);
- /*
- * Try to avoid locking the mutex for messages which can't
- * possibly be logged to any channels -- primarily debugging
- * messages that the debug level is not high enough to print.
- *
- * If the level is (mathematically) less than or equal to the
- * highest_level, or if there is a dynamic channel and the level is
- * less than or equal to the debug level, the main loop must be
- * entered to see if the message should really be output.
- *
- * NOTE: this is UNLOCKED access to the logconfig. However,
- * the worst thing that can happen is that a bad decision is made
- * about returning without logging, and that's not a big concern,
- * because that's a risk anyway if the logconfig is being
- * dynamically changed.
- */
- if (! (level <= lctx->logconfig->highest_level ||
- (lctx->logconfig->dynamic && level <= lctx->debug_level)))
+ if (! isc_log_wouldlog(lctx, level))
return;
time_string[0] = '\0';
* SOFTWARE.
*/
-/* $Id: socket.c,v 1.142.2.3 2000/08/15 01:30:34 gson Exp $ */
+/* $Id: socket.c,v 1.142.2.4 2000/08/22 01:45:28 bwelling Exp $ */
#include <config.h>
* DLVL(50) -- Event tracing, including receiving/sending completion events.
* DLVL(20) -- Socket creation/destruction.
*/
-#define TRACE DLVL(90)
-#define CORRECTNESS DLVL(70)
-#define IOEVENT DLVL(60)
-#define EVENT DLVL(50)
-#define CREATION DLVL(20)
+#define TRACE_LEVEL 90
+#define CORRECTNESS_LEVEL 70
+#define IOEVENT_LEVEL 60
+#define EVENT_LEVEL 50
+#define CREATION_LEVEL 20
+
+#define TRACE DLVL(TRACE_LEVEL)
+#define CORRECTNESS DLVL(CORRECTNESS_LEVEL)
+#define IOEVENT DLVL(IOEVENT_LEVEL)
+#define EVENT DLVL(EVENT_LEVEL)
+#define CREATION DLVL(CREATION_LEVEL)
typedef isc_event_t intev_t;
char msgbuf[2048];
va_list ap;
+ if (! isc_log_wouldlog(isc_lctx, level))
+ return;
+
va_start(ap, fmt);
vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap);
va_end(ap);
char peerbuf[256];
va_list ap;
+ if (! isc_log_wouldlog(isc_lctx, level))
+ return;
+
va_start(ap, fmt);
vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap);
va_end(ap);
if (SOFT_ERROR(errno))
return (DOIO_SOFT);
- socket_log(sock, NULL, IOEVENT,
- "doio_recv: recvmsg(%d) %d bytes, err %d/%s",
- sock->fd, cc, errno, strerror(errno));
+ if (isc_log_wouldlog(isc_lctx, IOEVENT_LEVEL))
+ socket_log(sock, NULL, IOEVENT,
+ "doio_recv: recvmsg(%d) %d bytes, err %d/%s",
+ sock->fd, cc, errno, strerror(errno));
#define SOFT_OR_HARD(_system, _isc) \
if (errno == _system) { \
* If some other error, ignore it as well and hope
* for the best, but log it.
*/
- socket_log(sock, NULL, TRACE,
- "accept() returned %d/%s", errno, strerror(errno));
+ if (isc_log_wouldlog(isc_lctx, TRACE_LEVEL))
+ socket_log(sock, NULL, TRACE,
+ "accept() returned %d/%s", errno,
+ strerror(errno));
fd = -1;
UNLOCK(&manager->lock);
cc = select(maxfd, &readfds, &writefds, NULL, NULL);
- manager_log(manager, IOEVENT,
- "select(%d, ...) == %d, errno %d/%s",
- maxfd, cc, errno, strerror(errno));
if (cc < 0) {
if (!SOFT_ERROR(errno))
FATAL_ERROR(__FILE__, __LINE__,