added cfg_obj_log()

This commit is contained in:
Andreas Gustafsson 2001-02-22 00:36:26 +00:00
parent 1b0fca7957
commit c396dc6551
2 changed files with 28 additions and 2 deletions

View file

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: cfg.h,v 1.6 2001/02/22 00:23:31 gson Exp $ */
/* $Id: cfg.h,v 1.7 2001/02/22 00:36:26 gson Exp $ */
#ifndef DNS_CFG_H
#define DNS_CFG_H 1
@ -247,6 +247,15 @@ void cfg_obj_destroy(cfg_parser_t *pctx, cfg_obj_t **obj);
* Destroy a configuration object.
*/
void
cfg_obj_log(cfg_parser_t *pctx, cfg_obj_t *obj, int level,
const char *fmt, ...);
/*
* Log a message concerning configuration object 'obj' to the logging
* channel of 'pctx', at log level 'level'. The message will be prefixed
* with the file name(s) and line number where 'obj' was defined.
*/
/*
* Configuration object types.
*/

View file

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: parser.c,v 1.11 2001/02/22 00:23:29 gson Exp $ */
/* $Id: parser.c,v 1.12 2001/02/22 00:36:24 gson Exp $ */
#include <config.h>
@ -3092,6 +3092,23 @@ parser_complain(cfg_parser_t *pctx, isc_boolean_t is_warning,
"%s%s%s%s", where, message, prep, tokenbuf);
}
void
cfg_obj_log(cfg_parser_t *pctx, cfg_obj_t *obj, int level, const char *fmt, ...)
{
va_list ap;
char msgbuf[2048];
if (! isc_log_wouldlog(pctx->lctx, level))
return;
vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap);
isc_log_write(pctx->lctx, CAT, MOD, level,
"%s:%u: %s",
obj->file == NULL ? "<unknown file>" : obj->file,
obj->line, msgbuf);
va_end(ap);
}
static isc_result_t
create_cfgobj(cfg_parser_t *pctx, cfg_type_t *type, cfg_obj_t **objp) {
cfg_obj_t *obj;