diff --git a/lib/isccfg/include/isccfg/cfg.h b/lib/isccfg/include/isccfg/cfg.h index 4a2b3c4c92..3b809af0a4 100644 --- a/lib/isccfg/include/isccfg/cfg.h +++ b/lib/isccfg/include/isccfg/cfg.h @@ -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. */ diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c index 2e8de09907..f87f3f12cb 100644 --- a/lib/isccfg/parser.c +++ b/lib/isccfg/parser.c @@ -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 @@ -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 ? "" : 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;