mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 15:05:23 +00:00
330. [func] New function isc_log_wouldlog().
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -1,3 +1,5 @@
|
||||
330. [func] New function isc_log_wouldlog().
|
||||
|
||||
329. [func] omapi_auth_register() now takes a size_t argument for
|
||||
the length of a key's secret data. Previously
|
||||
OMAPI only stored secrets up to the first NUL byte.
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: log.h,v 1.25 2000/06/19 21:45:03 explorer Exp $ */
|
||||
/* $Id: log.h,v 1.26 2000/07/13 00:18:53 gson Exp $ */
|
||||
|
||||
#ifndef ISC_LOG_H
|
||||
#define ISC_LOG_H 1
|
||||
@@ -627,6 +627,17 @@ isc_log_getdebuglevel(isc_log_t *lctx);
|
||||
* 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);
|
||||
/*
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: log.c,v 1.38 2000/06/23 17:52:20 tale Exp $ */
|
||||
/* $Id: log.c,v 1.39 2000/07/13 00:18:51 gson Exp $ */
|
||||
|
||||
/* Principal Authors: DCL */
|
||||
|
||||
@@ -1197,6 +1197,30 @@ isc_log_open(isc_logchannel_t *channel) {
|
||||
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.
|
||||
*/
|
||||
|
||||
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,
|
||||
@@ -1232,24 +1256,7 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
|
||||
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';
|
||||
|
Reference in New Issue
Block a user