2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 22:45:39 +00:00

Add isc_log_setcontext() to set the isc_lctx global (ala dns_lctx) and add module names for isc/socket

This commit is contained in:
Michael Graff
2000-05-03 21:09:34 +00:00
parent deb7afc49f
commit 1a487fb7d2
2 changed files with 56 additions and 8 deletions

View File

@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: log.h,v 1.18 2000/04/28 00:36:55 tale Exp $ */
/* $Id: log.h,v 1.19 2000/05/03 21:09:34 explorer Exp $ */
#ifndef ISC_LOG_H
#define ISC_LOG_H 1
@@ -119,19 +119,25 @@ typedef union isc_logdestination {
} isc_logdestination_t;
/*
* The built-in categories of libisc.a. Currently only one is available,
* the category named "default".
* The built-in categories of libisc.
*
* Each library registering categories should provide library_LOGCATEGORY_name
* definitions with indexes into its isc_logcategory structure corresponding to
* the order of the names. This should also be done for modules, but currently
* libisc.a has no defined modules.
* the order of the names.
*/
extern isc_logcategory_t isc_categories[];
extern isc_log_t *isc_lctx;
extern isc_logmodule_t isc_modules[];
/*
* Do not log directly to DEFAULT. Use another category. When in doubt,
* use GENERAL.
*/
#define ISC_LOGCATEGORY_DEFAULT (&isc_categories[0])
#define ISC_LOGCATEGORY_GENERAL (&isc_categories[1])
#define ISC_LOGMODULE_SOCKET (&isc_modules[0])
isc_result_t
isc_log_create(isc_mem_t *mctx, isc_log_t **lctxp, isc_logconfig_t **lcfgp);
/*
@@ -744,6 +750,16 @@ isc_log_modulebyname(isc_log_t *lctx, const char *name);
* NULL if no module exists by that name.
*/
void
isc_log_setcontext(isc_log_t *lctx);
/*
* Sets the context used by the libisc for logging.
*
* Requires:
* lctx be a valid context.
* This function must not have been previously called.
*/
ISC_LANG_ENDDECLS
#endif /* ISC_LOG_H */

View File

@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: log.c,v 1.28 2000/04/28 17:29:25 explorer Exp $ */
/* $Id: log.c,v 1.29 2000/05/03 21:09:33 explorer Exp $ */
/* Principal Authors: DCL */
@@ -153,7 +153,12 @@ struct isc_log {
* Used when ISC_LOG_PRINTLEVEL is enabled for a channel.
*/
static const char *log_level_strings[] = {
"debug", "info", "notice", "warning", "error", "critical"
"debug",
"info",
"notice",
"warning",
"error",
"critical"
};
/*
@@ -161,7 +166,12 @@ static const char *log_level_strings[] = {
* XXXDCL This will need modification for NT.
*/
static const int syslog_map[] = {
LOG_DEBUG, LOG_INFO, LOG_NOTICE, LOG_WARNING, LOG_ERR, LOG_CRIT
LOG_DEBUG,
LOG_INFO,
LOG_NOTICE,
LOG_WARNING,
LOG_ERR,
LOG_CRIT
};
/*
@@ -178,6 +188,14 @@ isc_logcategory_t isc_categories[] = {
{ NULL, 0 }
};
/*
* See above comment for categories, and apply it to modules.
*/
isc_logmodule_t isc_modules[] = {
{ "socket", 0 },
{ NULL, 0 }
};
/*
* This essentially constant structure must be filled in at run time,
* because its channel member is pointed to a channel that is created
@@ -185,6 +203,11 @@ isc_logcategory_t isc_categories[] = {
*/
static isc_logchannellist_t default_channel;
/*
* libisc logs to this context.
*/
isc_log_t *isc_lctx = NULL;
/*
* Forward declarations.
*/
@@ -255,6 +278,7 @@ isc_log_create(isc_mem_t *mctx, isc_log_t **lctxp, isc_logconfig_t **lcfgp) {
lctx->magic = LCTX_MAGIC;
isc_log_registercategories(lctx, isc_categories);
isc_log_registermodules(lctx, isc_modules);
result = isc_logconfig_create(lctx, &lcfg);
} else
@@ -786,6 +810,14 @@ isc_log_vwrite1(isc_log_t *lctx, isc_logcategory_t *category,
isc_log_doit(lctx, category, module, level, ISC_TRUE, format, args);
}
void
isc_log_setcontext(isc_log_t *lctx)
{
REQUIRE(isc_lctx == NULL);
isc_lctx = lctx;
}
void
isc_log_setdebuglevel(isc_log_t *lctx, unsigned int level) {
REQUIRE(VALID_CONTEXT(lctx));