mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 06:55:30 +00:00
Updated API to support i18n message arguments to isc_log_{,v}write{,1}.
Provided isc_log_i{,v}write{,1}, with appropriate macro substitutions, for files that are not yet converted to the new API. When everything is converted, the added functions will be removed.
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: log.h,v 1.31 2000/11/27 17:49:41 gson Exp $ */
|
/* $Id: log.h,v 1.32 2000/12/07 19:30:28 tale Exp $ */
|
||||||
|
|
||||||
#ifndef ISC_LOG_H
|
#ifndef ISC_LOG_H
|
||||||
#define ISC_LOG_H 1
|
#define ISC_LOG_H 1
|
||||||
@@ -28,8 +28,6 @@
|
|||||||
#include <isc/lang.h>
|
#include <isc/lang.h>
|
||||||
#include <isc/types.h>
|
#include <isc/types.h>
|
||||||
|
|
||||||
ISC_LANG_BEGINDECLS
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Severity levels, patterned after Unix's syslog levels.
|
* Severity levels, patterned after Unix's syslog levels.
|
||||||
*
|
*
|
||||||
@@ -140,6 +138,8 @@ extern isc_logmodule_t isc_modules[];
|
|||||||
|
|
||||||
#define ISC_LOGMODULE_SOCKET (&isc_modules[0])
|
#define ISC_LOGMODULE_SOCKET (&isc_modules[0])
|
||||||
|
|
||||||
|
ISC_LANG_BEGINDECLS
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
isc_log_create(isc_mem_t *mctx, isc_log_t **lctxp, isc_logconfig_t **lcfgp);
|
isc_log_create(isc_mem_t *mctx, isc_log_t **lctxp, isc_logconfig_t **lcfgp);
|
||||||
/*
|
/*
|
||||||
@@ -499,8 +499,18 @@ isc_log_usechannel(isc_logconfig_t *lcfg, const char *name,
|
|||||||
|
|
||||||
void
|
void
|
||||||
isc_log_write(isc_log_t *lctx, isc_logcategory_t *category,
|
isc_log_write(isc_log_t *lctx, isc_logcategory_t *category,
|
||||||
isc_logmodule_t *module, int level, const char *format, ...)
|
isc_logmodule_t *module, int level,
|
||||||
|
isc_msgcat_t *msgcat, int msgset, int message,
|
||||||
|
const char *format, ...)
|
||||||
|
ISC_FORMAT_PRINTF(8, 9);
|
||||||
|
void
|
||||||
|
isc_log_iwrite(isc_log_t *lctx, isc_logcategory_t *category,
|
||||||
|
isc_logmodule_t *module, int level,
|
||||||
|
const char *format, ...)
|
||||||
ISC_FORMAT_PRINTF(5, 6);
|
ISC_FORMAT_PRINTF(5, 6);
|
||||||
|
#ifndef ISC_LOG_MSGCATARGS
|
||||||
|
#define isc_log_write isc_log_iwrite
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
* Write a message to the log channels.
|
* Write a message to the log channels.
|
||||||
*
|
*
|
||||||
@@ -536,9 +546,18 @@ ISC_FORMAT_PRINTF(5, 6);
|
|||||||
|
|
||||||
void
|
void
|
||||||
isc_log_vwrite(isc_log_t *lctx, isc_logcategory_t *category,
|
isc_log_vwrite(isc_log_t *lctx, isc_logcategory_t *category,
|
||||||
isc_logmodule_t *module, int level, const char *format,
|
isc_logmodule_t *module, int level,
|
||||||
va_list args)
|
isc_msgcat_t *msgcat, int msgset, int message,
|
||||||
|
const char *format, va_list args)
|
||||||
|
ISC_FORMAT_PRINTF(8, 0);
|
||||||
|
void
|
||||||
|
isc_log_ivwrite(isc_log_t *lctx, isc_logcategory_t *category,
|
||||||
|
isc_logmodule_t *module, int level,
|
||||||
|
const char *format, va_list args)
|
||||||
ISC_FORMAT_PRINTF(5, 0);
|
ISC_FORMAT_PRINTF(5, 0);
|
||||||
|
#ifndef ISC_LOG_MSGCATARGS
|
||||||
|
#define isc_log_vwrite isc_log_ivwrite
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
* Write a message to the log channels.
|
* Write a message to the log channels.
|
||||||
*
|
*
|
||||||
@@ -574,8 +593,18 @@ ISC_FORMAT_PRINTF(5, 0);
|
|||||||
|
|
||||||
void
|
void
|
||||||
isc_log_write1(isc_log_t *lctx, isc_logcategory_t *category,
|
isc_log_write1(isc_log_t *lctx, isc_logcategory_t *category,
|
||||||
isc_logmodule_t *module, int level, const char *format, ...)
|
isc_logmodule_t *module, int level,
|
||||||
|
isc_msgcat_t *msgcat, int msgset, int message,
|
||||||
|
const char *format, ...)
|
||||||
|
ISC_FORMAT_PRINTF(8, 9);
|
||||||
|
void
|
||||||
|
isc_log_iwrite1(isc_log_t *lctx, isc_logcategory_t *category,
|
||||||
|
isc_logmodule_t *module, int level,
|
||||||
|
const char *format, ...)
|
||||||
ISC_FORMAT_PRINTF(5, 6);
|
ISC_FORMAT_PRINTF(5, 6);
|
||||||
|
#ifndef ISC_LOG_MSGCATARGS
|
||||||
|
#define isc_log_write1 isc_log_iwrite1
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
* Write a message to the log channels, pruning duplicates that occur within
|
* Write a message to the log channels, pruning duplicates that occur within
|
||||||
* a configurable amount of seconds (see isc_log_[sg]etduplicateinterval).
|
* a configurable amount of seconds (see isc_log_[sg]etduplicateinterval).
|
||||||
@@ -584,9 +613,18 @@ ISC_FORMAT_PRINTF(5, 6);
|
|||||||
|
|
||||||
void
|
void
|
||||||
isc_log_vwrite1(isc_log_t *lctx, isc_logcategory_t *category,
|
isc_log_vwrite1(isc_log_t *lctx, isc_logcategory_t *category,
|
||||||
isc_logmodule_t *module, int level, const char *format,
|
isc_logmodule_t *module, int level,
|
||||||
va_list args)
|
isc_msgcat_t *msgcat, int msgset, int message,
|
||||||
|
const char *format, va_list args)
|
||||||
|
ISC_FORMAT_PRINTF(8, 0);
|
||||||
|
void
|
||||||
|
isc_log_ivwrite1(isc_log_t *lctx, isc_logcategory_t *category,
|
||||||
|
isc_logmodule_t *module, int level, const char *format,
|
||||||
|
va_list args)
|
||||||
ISC_FORMAT_PRINTF(5, 0);
|
ISC_FORMAT_PRINTF(5, 0);
|
||||||
|
#ifndef ISC_LOG_MSGCATARGS
|
||||||
|
#define isc_log_vwrite1 isc_log_ivwrite1
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
* Write a message to the log channels, pruning duplicates that occur within
|
* Write a message to the log channels, pruning duplicates that occur within
|
||||||
* a configurable amount of seconds (see isc_log_[sg]etduplicateinterval).
|
* a configurable amount of seconds (see isc_log_[sg]etduplicateinterval).
|
||||||
|
105
lib/isc/log.c
105
lib/isc/log.c
@@ -15,10 +15,12 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: log.c,v 1.50 2000/12/06 00:30:01 tale Exp $ */
|
/* $Id: log.c,v 1.51 2000/12/07 19:30:26 tale Exp $ */
|
||||||
|
|
||||||
/* Principal Authors: DCL */
|
/* Principal Authors: DCL */
|
||||||
|
|
||||||
|
#define ISC_LOG_MSGCATARGS
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -226,6 +228,7 @@ roll_log(isc_logchannel_t *channel);
|
|||||||
static void
|
static void
|
||||||
isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
|
isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
|
||||||
isc_logmodule_t *module, int level, isc_boolean_t write_once,
|
isc_logmodule_t *module, int level, isc_boolean_t write_once,
|
||||||
|
isc_msgcat_t *msgcat, int msgset, int msg,
|
||||||
const char *format, va_list args);
|
const char *format, va_list args);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -801,8 +804,9 @@ isc_log_usechannel(isc_logconfig_t *lcfg, const char *name,
|
|||||||
|
|
||||||
void
|
void
|
||||||
isc_log_write(isc_log_t *lctx, isc_logcategory_t *category,
|
isc_log_write(isc_log_t *lctx, isc_logcategory_t *category,
|
||||||
isc_logmodule_t *module, int level, const char *format, ...)
|
isc_logmodule_t *module, int level,
|
||||||
|
isc_msgcat_t *msgcat, int msgset, int msg,
|
||||||
|
const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
@@ -811,26 +815,29 @@ isc_log_write(isc_log_t *lctx, isc_logcategory_t *category,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
isc_log_doit(lctx, category, module, level, ISC_FALSE, format, args);
|
isc_log_doit(lctx, category, module, level, ISC_FALSE,
|
||||||
|
msgcat, msgset, msg, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
isc_log_vwrite(isc_log_t *lctx, isc_logcategory_t *category,
|
isc_log_vwrite(isc_log_t *lctx, isc_logcategory_t *category,
|
||||||
isc_logmodule_t *module, int level,
|
isc_logmodule_t *module, int level,
|
||||||
|
isc_msgcat_t *msgcat, int msgset, int msg,
|
||||||
const char *format, va_list args)
|
const char *format, va_list args)
|
||||||
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Contract checking is done in isc_log_doit().
|
* Contract checking is done in isc_log_doit().
|
||||||
*/
|
*/
|
||||||
isc_log_doit(lctx, category, module, level, ISC_FALSE, format, args);
|
isc_log_doit(lctx, category, module, level, ISC_FALSE,
|
||||||
|
msgcat, msgset, msg, format, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
isc_log_write1(isc_log_t *lctx, isc_logcategory_t *category,
|
isc_log_write1(isc_log_t *lctx, isc_logcategory_t *category,
|
||||||
isc_logmodule_t *module, int level, const char *format, ...)
|
isc_logmodule_t *module, int level,
|
||||||
|
isc_msgcat_t *msgcat, int msgset, int msg,
|
||||||
|
const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
@@ -839,20 +846,84 @@ isc_log_write1(isc_log_t *lctx, isc_logcategory_t *category,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
isc_log_doit(lctx, category, module, level, ISC_TRUE, format, args);
|
isc_log_doit(lctx, category, module, level, ISC_TRUE,
|
||||||
|
msgcat, msgset, msg, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
isc_log_vwrite1(isc_log_t *lctx, isc_logcategory_t *category,
|
isc_log_vwrite1(isc_log_t *lctx, isc_logcategory_t *category,
|
||||||
isc_logmodule_t *module, int level,
|
isc_logmodule_t *module, int level,
|
||||||
|
isc_msgcat_t *msgcat, int msgset, int msg,
|
||||||
const char *format, va_list args)
|
const char *format, va_list args)
|
||||||
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Contract checking is done in isc_log_doit().
|
* Contract checking is done in isc_log_doit().
|
||||||
*/
|
*/
|
||||||
isc_log_doit(lctx, category, module, level, ISC_TRUE, format, args);
|
isc_log_doit(lctx, category, module, level, ISC_TRUE,
|
||||||
|
msgcat, msgset, msg, format, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The isc_log_i*write*() functions are transitional functions which will
|
||||||
|
* be removed once all users of the old isc_log_*write* APIs have been
|
||||||
|
* converted to the new form (which added msgcat, msgset and msg parameters).
|
||||||
|
* They are used unless the calling module has ISC_LOG_MSGCATARGS defined.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
isc_log_iwrite(isc_log_t *lctx, isc_logcategory_t *category,
|
||||||
|
isc_logmodule_t *module, int level, const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Contract checking is done in isc_log_doit().
|
||||||
|
*/
|
||||||
|
|
||||||
|
va_start(args, format);
|
||||||
|
isc_log_doit(lctx, category, module, level, ISC_FALSE,
|
||||||
|
NULL, 0, 0, format, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
isc_log_ivwrite(isc_log_t *lctx, isc_logcategory_t *category,
|
||||||
|
isc_logmodule_t *module, int level,
|
||||||
|
const char *format, va_list args)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Contract checking is done in isc_log_doit().
|
||||||
|
*/
|
||||||
|
isc_log_doit(lctx, category, module, level, ISC_FALSE,
|
||||||
|
NULL, 0, 0, format, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
isc_log_iwrite1(isc_log_t *lctx, isc_logcategory_t *category,
|
||||||
|
isc_logmodule_t *module, int level, const char *format, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Contract checking is done in isc_log_doit().
|
||||||
|
*/
|
||||||
|
|
||||||
|
va_start(args, format);
|
||||||
|
isc_log_doit(lctx, category, module, level, ISC_TRUE,
|
||||||
|
NULL, 0, 0, format, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
isc_log_ivwrite1(isc_log_t *lctx, isc_logcategory_t *category,
|
||||||
|
isc_logmodule_t *module, int level,
|
||||||
|
const char *format, va_list args)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Contract checking is done in isc_log_doit().
|
||||||
|
*/
|
||||||
|
isc_log_doit(lctx, category, module, level, ISC_TRUE,
|
||||||
|
NULL, 0, 0, format, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -969,7 +1040,8 @@ assignchannel(isc_logconfig_t *lcfg, unsigned int category_id,
|
|||||||
|
|
||||||
new_item->channel = channel;
|
new_item->channel = channel;
|
||||||
new_item->module = module;
|
new_item->module = module;
|
||||||
ISC_LIST_PREPENDUNSAFE(lcfg->channellists[category_id], new_item, link);
|
ISC_LIST_PREPENDUNSAFE(lcfg->channellists[category_id],
|
||||||
|
new_item, link);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remember the highest logging level set by any channel in the
|
* Remember the highest logging level set by any channel in the
|
||||||
@@ -1231,11 +1303,13 @@ isc_log_wouldlog(isc_log_t *lctx, int level) {
|
|||||||
static void
|
static void
|
||||||
isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
|
isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
|
||||||
isc_logmodule_t *module, int level, isc_boolean_t write_once,
|
isc_logmodule_t *module, int level, isc_boolean_t write_once,
|
||||||
|
isc_msgcat_t *msgcat, int msgset, int msg,
|
||||||
const char *format, va_list args)
|
const char *format, va_list args)
|
||||||
{
|
{
|
||||||
int syslog_level;
|
int syslog_level;
|
||||||
char time_string[64];
|
char time_string[64];
|
||||||
char level_string[24];
|
char level_string[24];
|
||||||
|
const char *iformat;
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
isc_boolean_t matched = ISC_FALSE;
|
isc_boolean_t matched = ISC_FALSE;
|
||||||
isc_boolean_t printtime, printtag;
|
isc_boolean_t printtime, printtag;
|
||||||
@@ -1266,6 +1340,11 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
|
|||||||
if (! isc_log_wouldlog(lctx, level))
|
if (! isc_log_wouldlog(lctx, level))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (msgcat != NULL)
|
||||||
|
iformat = isc_msgcat_get(msgcat, msgset, msg, format);
|
||||||
|
else
|
||||||
|
iformat = format;
|
||||||
|
|
||||||
time_string[0] = '\0';
|
time_string[0] = '\0';
|
||||||
level_string[0] = '\0';
|
level_string[0] = '\0';
|
||||||
|
|
||||||
@@ -1394,7 +1473,7 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
|
|||||||
*/
|
*/
|
||||||
if (lctx->buffer[0] == '\0') {
|
if (lctx->buffer[0] == '\0') {
|
||||||
(void)vsnprintf(lctx->buffer, sizeof(lctx->buffer),
|
(void)vsnprintf(lctx->buffer, sizeof(lctx->buffer),
|
||||||
format, args);
|
iformat, args);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for duplicates.
|
* Check for duplicates.
|
||||||
|
Reference in New Issue
Block a user