isc_logconfig_t *logconfig = NULL;
isc_log_t *log = NULL;
- RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig) == ISC_R_SUCCESS);
+ isc_log_create(mctx, &log, &logconfig);
isc_log_registercategories(log, categories);
isc_log_setcontext(log);
dns_log_init(log);
destination.file.name = NULL;
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
- RUNTIME_CHECK(isc_log_createchannel(logconfig, "stderr",
- ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC,
- &destination, 0) == ISC_R_SUCCESS);
+ isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
+ ISC_LOG_DYNAMIC, &destination, 0);
+
RUNTIME_CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL) ==
ISC_R_SUCCESS);
isc_logdestination_t destination;
isc_logconfig_t *logconfig = NULL;
- result = isc_log_create(mctx, &lctx, &logconfig);
- if (result != ISC_R_SUCCESS) {
- fatal("Couldn't set up logging");
- }
-
+ isc_log_create(mctx, &lctx, &logconfig);
isc_log_registercategories(lctx, categories);
isc_log_registermodules(lctx, modules);
isc_log_setcontext(lctx);
destination.file.name = NULL;
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
-
- result = isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
- ISC_LOG_DYNAMIC, &destination,
- ISC_LOG_PRINTPREFIX);
- if (result != ISC_R_SUCCESS) {
- fatal("Couldn't set up log channel 'stderr'");
- }
+ isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
+ ISC_LOG_DYNAMIC, &destination,
+ ISC_LOG_PRINTPREFIX);
isc_log_setdebuglevel(lctx, loglevel);
-
- result = isc_log_settag(logconfig, ";; ");
- if (result != ISC_R_SUCCESS) {
- fatal("Couldn't set log tag");
- }
+ isc_log_settag(logconfig, ";; ");
result = isc_log_usechannel(logconfig, "stderr",
ISC_LOGCATEGORY_DEFAULT, NULL);
}
if (resolve_trace && loglevel < 1) {
- result = isc_log_createchannel(
- logconfig, "resolver", ISC_LOG_TOFILEDESC,
- ISC_LOG_DEBUG(1), &destination, ISC_LOG_PRINTPREFIX);
- if (result != ISC_R_SUCCESS) {
- fatal("Couldn't set up log channel 'resolver'");
- }
+ isc_log_createchannel(logconfig, "resolver", ISC_LOG_TOFILEDESC,
+ ISC_LOG_DEBUG(1), &destination,
+ ISC_LOG_PRINTPREFIX);
result = isc_log_usechannel(logconfig, "resolver",
DNS_LOGCATEGORY_RESOLVER,
}
if (validator_trace && loglevel < 3) {
- result = isc_log_createchannel(
- logconfig, "validator", ISC_LOG_TOFILEDESC,
- ISC_LOG_DEBUG(3), &destination, ISC_LOG_PRINTPREFIX);
- if (result != ISC_R_SUCCESS) {
- fatal("Couldn't set up log channel 'validator'");
- }
+ isc_log_createchannel(logconfig, "validator",
+ ISC_LOG_TOFILEDESC, ISC_LOG_DEBUG(3),
+ &destination, ISC_LOG_PRINTPREFIX);
result = isc_log_usechannel(logconfig, "validator",
DNS_LOGCATEGORY_DNSSEC,
}
if (message_trace && loglevel < 10) {
- result = isc_log_createchannel(
- logconfig, "messages", ISC_LOG_TOFILEDESC,
- ISC_LOG_DEBUG(10), &destination, ISC_LOG_PRINTPREFIX);
- if (result != ISC_R_SUCCESS) {
- fatal("Couldn't set up log channel 'messages'");
- }
+ isc_log_createchannel(logconfig, "messages", ISC_LOG_TOFILEDESC,
+ ISC_LOG_DEBUG(10), &destination,
+ ISC_LOG_PRINTPREFIX);
result = isc_log_usechannel(logconfig, "messages",
DNS_LOGCATEGORY_RESOLVER,
isc_mem_create(&mctx);
isc_mem_setname(mctx, "dig", NULL);
- result = isc_log_create(mctx, &lctx, &logconfig);
- check_result(result, "isc_log_create");
-
+ isc_log_create(mctx, &lctx, &logconfig);
isc_log_setcontext(lctx);
dns_log_init(lctx);
dns_log_setcontext(lctx);
void
setup_logging(isc_mem_t *mctx, isc_log_t **logp) {
- isc_result_t result;
isc_logdestination_t destination;
isc_logconfig_t *logconfig = NULL;
isc_log_t *log = NULL;
break;
}
- RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig) == ISC_R_SUCCESS);
+ isc_log_create(mctx, &log, &logconfig);
isc_log_setcontext(log);
dns_log_init(log);
dns_log_setcontext(log);
-
- RUNTIME_CHECK(isc_log_settag(logconfig, program) == ISC_R_SUCCESS);
+ isc_log_settag(logconfig, program);
/*
* Set up a channel similar to default_stderr except:
destination.file.name = NULL;
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
- result = isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
- level, &destination,
- ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL);
- check_result(result, "isc_log_createchannel()");
+ isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, level,
+ &destination,
+ ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL);
RUNTIME_CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL) ==
ISC_R_SUCCESS);
* as root.
*/
-isc_result_t
+void
named_log_setdefaultchannels(isc_logconfig_t *lcfg);
/*%
* Set up logging channels according to the named defaults, which
* this just means setting up default_debug.
*/
-isc_result_t
+void
named_log_setsafechannels(isc_logconfig_t *lcfg);
/*%
* Like named_log_setdefaultchannels(), but omits any logging to files.
/*
* Setup a logging context.
*/
- result = isc_log_create(named_g_mctx, &named_g_lctx, &lcfg);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
+ isc_log_create(named_g_mctx, &named_g_lctx, &lcfg);
/*
* named-checktool.c:setup_logging() needs to be kept in sync.
ns_log_setcontext(named_g_lctx);
if (safe) {
- result = named_log_setsafechannels(lcfg);
+ named_log_setsafechannels(lcfg);
} else {
- result = named_log_setdefaultchannels(lcfg);
- }
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
+ named_log_setdefaultchannels(lcfg);
}
result = named_log_setdefaultcategory(lcfg);
return (result);
}
-isc_result_t
+void
named_log_setdefaultchannels(isc_logconfig_t *lcfg) {
- isc_result_t result;
isc_logdestination_t destination;
/*
destination.file.name = "named.run";
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
- result = isc_log_createchannel(
- lcfg, "default_debug", ISC_LOG_TOFILE, ISC_LOG_DYNAMIC,
- &destination, ISC_LOG_PRINTTIME | ISC_LOG_DEBUGONLY);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
+ isc_log_createchannel(lcfg, "default_debug", ISC_LOG_TOFILE,
+ ISC_LOG_DYNAMIC, &destination,
+ ISC_LOG_PRINTTIME | ISC_LOG_DEBUGONLY);
}
if (named_g_logfile != NULL) {
destination.file.name = named_g_logfile;
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
- result = isc_log_createchannel(
- lcfg, "default_logfile", ISC_LOG_TOFILE,
- ISC_LOG_DYNAMIC, &destination,
- ISC_LOG_PRINTTIME | ISC_LOG_PRINTCATEGORY |
- ISC_LOG_PRINTLEVEL);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
+ isc_log_createchannel(lcfg, "default_logfile", ISC_LOG_TOFILE,
+ ISC_LOG_DYNAMIC, &destination,
+ ISC_LOG_PRINTTIME |
+ ISC_LOG_PRINTCATEGORY |
+ ISC_LOG_PRINTLEVEL);
}
#if ISC_FACILITY != LOG_DAEMON
destination.facility = ISC_FACILITY;
- result = isc_log_createchannel(lcfg, "default_syslog", ISC_LOG_TOSYSLOG,
- ISC_LOG_INFO, &destination, 0);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
+ isc_log_createchannel(lcfg, "default_syslog", ISC_LOG_TOSYSLOG,
+ ISC_LOG_INFO, &destination, 0);
#endif /* if ISC_FACILITY != LOG_DAEMON */
/*
* Set the initial debug level.
*/
isc_log_setdebuglevel(named_g_lctx, named_g_debuglevel);
-
- result = ISC_R_SUCCESS;
-
-cleanup:
- return (result);
}
-isc_result_t
+void
named_log_setsafechannels(isc_logconfig_t *lcfg) {
- isc_result_t result;
isc_logdestination_t destination;
if (!named_g_logstderr) {
- result = isc_log_createchannel(lcfg, "default_debug",
- ISC_LOG_TONULL, ISC_LOG_DYNAMIC,
- NULL, 0);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
+ isc_log_createchannel(lcfg, "default_debug", ISC_LOG_TONULL,
+ ISC_LOG_DYNAMIC, NULL, 0);
/*
* Setting the debug level to zero should get the output
destination.file.name = named_g_logfile;
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
- result = isc_log_createchannel(
- lcfg, "default_logfile", ISC_LOG_TOFILE,
- ISC_LOG_DYNAMIC, &destination,
- ISC_LOG_PRINTTIME | ISC_LOG_PRINTCATEGORY |
- ISC_LOG_PRINTLEVEL);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
+ isc_log_createchannel(lcfg, "default_logfile", ISC_LOG_TOFILE,
+ ISC_LOG_DYNAMIC, &destination,
+ ISC_LOG_PRINTTIME |
+ ISC_LOG_PRINTCATEGORY |
+ ISC_LOG_PRINTLEVEL);
}
#if ISC_FACILITY != LOG_DAEMON
destination.facility = ISC_FACILITY;
- result = isc_log_createchannel(lcfg, "default_syslog", ISC_LOG_TOSYSLOG,
- ISC_LOG_INFO, &destination, 0);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
+ isc_log_createchannel(lcfg, "default_syslog", ISC_LOG_TOSYSLOG,
+ ISC_LOG_INFO, &destination, 0);
#endif /* if ISC_FACILITY != LOG_DAEMON */
-
- result = ISC_R_SUCCESS;
-
-cleanup:
- return (result);
}
isc_result_t
*/
static isc_result_t
channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig) {
- isc_result_t result;
+ isc_result_t result = ISC_R_SUCCESS;
isc_logdestination_t dest;
unsigned int type;
unsigned int flags = 0;
}
}
- if (logconfig == NULL) {
- result = ISC_R_SUCCESS;
- } else {
- result = isc_log_createchannel(logconfig, channelname, type,
- level, &dest, flags);
+ if (logconfig != NULL) {
+ isc_log_createchannel(logconfig, channelname, type, level,
+ &dest, flags);
}
- if (result == ISC_R_SUCCESS && type == ISC_LOG_TOFILE) {
+ if (type == ISC_LOG_TOFILE) {
FILE *fp;
/*
const cfg_obj_t *catname;
if (logconfig != NULL) {
- CHECK(named_log_setdefaultchannels(logconfig));
+ named_log_setdefaultchannels(logconfig);
}
(void)cfg_map_get(logstmt, "channel", &channels);
} else {
const cfg_obj_t *logobj = NULL;
- CHECKM(isc_logconfig_create(named_g_lctx, &logc),
- "creating new logging configuration");
+ isc_logconfig_create(named_g_lctx, &logc);
logobj = NULL;
(void)cfg_map_get(config, "logging", &logobj);
CHECKM(named_logconfig(logc, logobj), "configuring "
"logging");
} else {
- CHECKM(named_log_setdefaultchannels(logc),
- "setting up default logging channels");
+ named_log_setdefaultchannels(logc);
CHECKM(named_log_setunmatchedcategory(logc),
"setting up default 'category unmatched'");
CHECKM(named_log_setdefaultcategory(logc),
"setting up default 'category default'");
}
- CHECKM(isc_logconfig_use(named_g_lctx, logc),
- "installing logging configuration");
+ isc_logconfig_use(named_g_lctx, logc);
logc = NULL;
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
dns_result_register();
- result = isc_log_create(gmctx, &glctx, &logconfig);
- check_result(result, "isc_log_create");
-
+ isc_log_create(gmctx, &glctx, &logconfig);
isc_log_setcontext(glctx);
dns_log_init(glctx);
dns_log_setcontext(glctx);
isc_taskmgr_create(rndc_mctx, 1, 0, NULL, &taskmgr));
DO("create task", isc_task_create(taskmgr, 0, &task));
- DO("create logging context",
- isc_log_create(rndc_mctx, &log, &logconfig));
+ isc_log_create(rndc_mctx, &log, &logconfig);
isc_log_setcontext(log);
- DO("setting log tag", isc_log_settag(logconfig, progname));
+ isc_log_settag(logconfig, progname);
logdest.file.stream = stderr;
logdest.file.name = NULL;
logdest.file.versions = ISC_LOG_ROLLNEVER;
logdest.file.maximum_size = 0;
- DO("creating log channel",
- isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
- ISC_LOG_INFO, &logdest,
- ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL));
+ isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
+ ISC_LOG_INFO, &logdest,
+ ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL);
DO("enabling log channel",
isc_log_usechannel(logconfig, "stderr", NULL, NULL));
isc_mem_create(&mctx);
- result = isc_log_create(mctx, &lctx, &lcfg);
- check_result(result, "isc_log_create()");
+ isc_log_create(mctx, &lctx, &lcfg);
isc_log_setcontext(lctx);
/*
destination.file.name = NULL;
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
- result = isc_log_createchannel(lcfg, "_default", ISC_LOG_TOFILEDESC,
- ISC_LOG_DYNAMIC, &destination,
- ISC_LOG_PRINTTIME);
- check_result(result, "isc_log_createchannel()");
+ isc_log_createchannel(lcfg, "_default", ISC_LOG_TOFILEDESC,
+ ISC_LOG_DYNAMIC, &destination, ISC_LOG_PRINTTIME);
+
result = isc_log_usechannel(lcfg, "_default", NULL, NULL);
check_result(result, "isc_log_usechannel()");
CHECK(dst_lib_init(mctx, NULL));
dst_active = true;
- CHECK(isc_log_create(mctx, &lctx, &logconfig));
+ isc_log_create(mctx, &lctx, &logconfig);
isc_log_registercategories(lctx, categories);
isc_log_setcontext(lctx);
dns_log_init(lctx);
destination.file.name = NULL;
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
- CHECK(isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
- ISC_LOG_DYNAMIC, &destination, 0));
+ isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
+ ISC_LOG_DYNAMIC, &destination, 0);
+
CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL));
dns_result_register();
isc_mempool_create(mctx, sizeof(client_t), &cmp);
isc_mempool_setname(cmp, "adb test clients");
- result = isc_log_create(mctx, &lctx, &lcfg);
- check_result(result, "isc_log_create()");
+ isc_log_create(mctx, &lctx, &lcfg);
isc_log_setcontext(lctx);
dns_log_init(lctx);
dns_log_setcontext(lctx);
destination.file.name = NULL;
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
- result = isc_log_createchannel(lcfg, "_default", ISC_LOG_TOFILEDESC,
- ISC_LOG_DYNAMIC, &destination,
- ISC_LOG_PRINTTIME);
- check_result(result, "isc_log_createchannel()");
+ isc_log_createchannel(lcfg, "_default", ISC_LOG_TOFILEDESC,
+ ISC_LOG_DYNAMIC, &destination, ISC_LOG_PRINTTIME);
+
result = isc_log_usechannel(lcfg, "_default", NULL, NULL);
check_result(result, "isc_log_usechannel()");
/*
* Setup a logging context.
*/
- RUNTIME_CHECK(isc_log_create(mctx, &lctx, &lcfg) == ISC_R_SUCCESS);
+ isc_log_create(mctx, &lctx, &lcfg);
isc_log_setcontext(lctx);
dns_log_init(lctx);
dns_log_setcontext(lctx);
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
flags = ISC_LOG_PRINTTIME;
- RUNTIME_CHECK(isc_log_createchannel(lcfg, "_default",
- ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC,
- &destination,
- flags) == ISC_R_SUCCESS);
+ isc_log_createchannel(lcfg, "_default", ISC_LOG_TOFILEDESC,
+ ISC_LOG_DYNAMIC, &destination, flags);
+
RUNTIME_CHECK(isc_log_usechannel(lcfg, "_default", NULL, NULL) ==
ISC_R_SUCCESS);
isc_log_setdebuglevel(lctx, level);
DNS_DBFIND_VALIDATEGLUE);
break;
case 'l':
- RUNTIME_CHECK(isc_log_create(mctx, &lctx, NULL) ==
- ISC_R_SUCCESS);
+ isc_log_create(mctx, &lctx, NULL);
isc_log_setcontext(lctx);
dns_log_init(lctx);
dns_log_setcontext(lctx);
mctx = NULL;
isc_mem_create(&mctx);
- RUNCHECK(isc_log_create(mctx, &lctx, &lcfg));
+ isc_log_create(mctx, &lctx, &lcfg);
isc_log_setcontext(lctx);
dns_log_init(lctx);
dns_log_setcontext(lctx);
destination.file.name = NULL;
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
- RUNCHECK(isc_log_createchannel(lcfg, "_default", ISC_LOG_TOFILEDESC,
- ISC_LOG_DYNAMIC, &destination,
- ISC_LOG_PRINTTIME));
+ isc_log_createchannel(lcfg, "_default", ISC_LOG_TOFILEDESC,
+ ISC_LOG_DYNAMIC, &destination, ISC_LOG_PRINTTIME);
+
RUNCHECK(isc_log_usechannel(lcfg, "_default", NULL, NULL));
isc_log_setdebuglevel(lctx, 9);
lcfg = NULL;
isc_mem_create(&mctx);
- CHECK(isc_log_create(mctx, &lctx, &lcfg));
+ isc_log_create(mctx, &lctx, &lcfg);
- CHECK(isc_log_settag(lcfg, progname));
+ isc_log_settag(lcfg, progname);
isc_log_setcontext(lctx);
dns_log_init(lctx);
destination.file.maximum_size = 1;
destination.file.versions = file_versions;
- CHECK(isc_log_createchannel(
+ isc_log_createchannel(
lcfg, "file_test", ISC_LOG_TOFILE, ISC_LOG_INFO, &destination,
ISC_LOG_PRINTTIME | ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL |
- ISC_LOG_PRINTCATEGORY | ISC_LOG_PRINTMODULE));
+ ISC_LOG_PRINTCATEGORY | ISC_LOG_PRINTMODULE);
/*
* Create a dynamic debugging channel to a file descriptor.
*/
destination.file.stream = stderr;
- CHECK(isc_log_createchannel(lcfg, "debug_test", ISC_LOG_TOFILEDESC,
- ISC_LOG_DYNAMIC, &destination,
- ISC_LOG_PRINTTIME | ISC_LOG_PRINTLEVEL |
- ISC_LOG_DEBUGONLY));
+ isc_log_createchannel(lcfg, "debug_test", ISC_LOG_TOFILEDESC,
+ ISC_LOG_DYNAMIC, &destination,
+ ISC_LOG_PRINTTIME | ISC_LOG_PRINTLEVEL |
+ ISC_LOG_DEBUGONLY);
/*
* Test the usability of the four predefined logging channels.
socketmgr = NULL;
RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS);
- RUNTIME_CHECK(isc_log_create(mctx, &lctx, &logconfig) == ISC_R_SUCCESS);
+ isc_log_create(mctx, &lctx, &logconfig);
s = NULL;
RUNTIME_CHECK(isc_socket_create(socketmgr, PF_INET, isc_sockettype_udp,
lctx = NULL;
lcfg = NULL;
- RUNCHECK(isc_log_create(mctx, &lctx, &lcfg));
+ isc_log_create(mctx, &lctx, &lcfg);
RUNCHECK(dst_lib_init(mctx, NULL));
isc_mem_create(&mctx);
CHECK(dst_lib_init(mctx, NULL), "dst_lib_init()");
- CHECK(isc_log_create(mctx, &log_, &logconfig), "isc_log_create()");
+ isc_log_create(mctx, &log_, &logconfig);
isc_log_setcontext(log_);
dns_log_init(log_);
dns_log_setcontext(log_);
- CHECK(isc_log_settag(logconfig, "bigkey"), "isc_log_settag()");
+ isc_log_settag(logconfig, "bigkey");
+
destination.file.stream = stderr;
destination.file.name = NULL;
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
- CHECK(isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
- level, &destination,
- ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL),
- "isc_log_createchannel()");
+ isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, level,
+ &destination,
+ ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL);
+
CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL), "isc_log_"
"usechannel("
")");
log = NULL;
logconfig = NULL;
- RUNCHECK(isc_log_create(mctx, &log, &logconfig));
+ isc_log_create(mctx, &log, &logconfig);
RUNCHECK(dst_lib_init(mctx, NULL));
log = NULL;
logconfig = NULL;
- RUNCHECK(isc_log_create(mctx, &log, &logconfig));
+ isc_log_create(mctx, &log, &logconfig);
RUNCHECK(dst_lib_init(mctx, NULL));
lctx = NULL;
lcfg = NULL;
- RUNCHECK(isc_log_create(mctx, &lctx, &lcfg));
+ isc_log_create(mctx, &lctx, &lcfg);
RUNCHECK(dst_lib_init(mctx, NULL));
isc_nonce_buf(cookie_secret, sizeof(cookie_secret));
isc_logconfig_t *logconfig = NULL;
isc_log_t *log = NULL;
- RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig) == ISC_R_SUCCESS);
+ isc_log_create(mctx, &log, &logconfig);
isc_log_setcontext(log);
dns_log_init(log);
dns_log_setcontext(log);
destination.file.name = NULL;
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
- RUNTIME_CHECK(isc_log_createchannel(logconfig, "stderr",
- ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC,
- &destination, 0) == ISC_R_SUCCESS);
+ isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
+ ISC_LOG_DYNAMIC, &destination, 0);
+
RUNTIME_CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL) ==
ISC_R_SUCCESS);
isc_mem_create(&ctx.mem);
- if (isc_log_create(ctx.mem, &ctx.log, &ctx.logcfg) != ISC_R_SUCCESS)
- goto done;
+ isc_log_create(ctx.mem, &ctx.log, &ctx.logcfg);
isc_log_setcontext(ctx.log);
dns_log_init(ctx.log);
isc_logconfig_t *lcfg;
isc_mem_create(&mctx);
- if (isc_log_create(mctx, &lctx, &lcfg) != ISC_R_SUCCESS))
- oops_it_didnt_work();
+ isc_log_create(mctx, &lctx, &lcfg);
3) Initialize any additional libraries. The convention for the name of
the initialization function is {library}_log_init, with just a pointer
and then configure newlcfg with isc_log_createchannel() and
isc_log_usechannel(). When it is all ready:
- result = isc_logconfig_use(lctx, newlcfg);
+ isc_logconfig_use(lctx, newlcfg);
If the new configuration is successfully installed, then the old one
will be destroyed, freeing all memory it used.
isc_logconfig_t *lcfg;
isc_mem_create(&mctx);
- if (isc_log_create(mctx, &lctx, &lcfg) != ISC_R_SUCCESS)) {
- oops_it_didnt_work();
- }
+ isc_log_create(mctx, &lctx, &lcfg) != ISC_R_SUCCESS);
1. Initialize any additional libraries. The convention for the name of
the initialization function is `{library}_log_init()`, with a pointer to
destination.file.name = "/var/log/example";
destination.file.maximum_size = 0; /* No byte limit. */
destination.file.versions = ISC_LOG_ROLLNEVER; /* External rolling. */
- result = isc_log_createchannel(lcfg, "sample1", ISC_LOG_TOFILE,
- ISC_LOG_DYNAMIC, &destination,
- ISC_LOG_PRINTTIME);
- if (result != ISC_R_SUCCESS)
- oops_it_didnt_work();
+ isc_log_createchannel(lcfg, "sample1", ISC_LOG_TOFILE, ISC_LOG_DYNAMIC,
+ &destination, ISC_LOG_PRINTTIME);
destination.file.stream = stdout;
- result = isc_log_createchannel(lcfg, "sample2", ISC_LOG_TOFILEDESC,
- ISC_LOG_INFO, &destination,
- ISC_LOG_PRINTTIME);
- if (result != ISC_R_SUCCESS)
- oops_it_didnt_work();
+ isc_log_createchannel(lcfg, "sample2", ISC_LOG_TOFILEDESC,
+ ISC_LOG_INFO, &destination, ISC_LOG_PRINTTIME);
destination.facility = LOG_ERR;
- result = isc_log_createchannel(lcfg, "sample3", ISC_LOG_SYSLOG,
- ISC_LOG_ERROR, &destination, 0);
- if (result != ISC_R_SUCCESS)
- oops_it_didnt_work();
+ isc_log_createchannel(lcfg, "sample3", ISC_LOG_SYSLOG, ISC_LOG_ERROR,
+ &destination, 0);
`ISC_LOG_DYNAMIC` is used to define a channel that wants any of the
messages up to the current debugging level of the program.
goto cleanup;
}
#if 0
- result = isc_log_create(mctx, &lctx, &logconfig);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
+ isc_log_create(mctx, &lctx, &logconfig);
isc_log_setcontext(lctx);
dns_log_init(lctx);
dns_log_setcontext(lctx);
isc_logconfig_t *logconfig = NULL;
INSIST(lctx == NULL);
- CHECK(isc_log_create(dt_mctx, &lctx, &logconfig));
-
+ isc_log_create(dt_mctx, &lctx, &logconfig);
isc_log_registercategories(lctx, categories);
isc_log_setcontext(lctx);
dns_log_init(lctx);
destination.file.name = NULL;
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
- CHECK(isc_log_createchannel(logconfig, "stderr",
- ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC,
- &destination, 0));
+ isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
+ ISC_LOG_DYNAMIC, &destination, 0);
CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL));
}
ISC_LANG_BEGINDECLS
-isc_result_t
+void
isc_log_create(isc_mem_t *mctx, isc_log_t **lctxp, isc_logconfig_t **lcfgp);
/*%<
* Establish a new logging context, with default channels.
*\li *lcfgp will point to a valid logging configuration if all of the
* necessary memory was allocated, or NULL otherwise.
*\li On failure, no additional memory is allocated.
- *
- * Returns:
- *\li #ISC_R_SUCCESS Success
- *\li #ISC_R_NOMEMORY Resource limit: Out of memory
*/
-isc_result_t
+void
isc_logconfig_create(isc_log_t *lctx, isc_logconfig_t **lcfgp);
/*%<
* Create the data structure that holds all of the configurable information
*\li *lcfgp will point to a valid logging context if all of the necessary
* memory was allocated, or NULL otherwise.
*\li On failure, no additional memory is allocated.
- *
- * Returns:
- *\li #ISC_R_SUCCESS Success
- *\li #ISC_R_NOMEMORY Resource limit: Out of memory
*/
-isc_result_t
+void
isc_logconfig_use(isc_log_t *lctx, isc_logconfig_t *lcfg);
/*%<
* Associate a new configuration with a logging context.
*
* Ensures:
*\li Future calls to isc_log_write will use the new configuration.
- *
- * Returns:
- *\li #ISC_R_SUCCESS Success
- *\li #ISC_R_NOMEMORY Resource limit: Out of memory
*/
void
* used with isc_log_usechannel() and isc_log_write().
*/
-isc_result_t
+void
isc_log_createchannel(isc_logconfig_t *lcfg, const char *name,
unsigned int type, int level,
const isc_logdestination_t *destination,
* No additional memory is being used by the logging context.
* Any channel that previously existed with the given name
* is not redefined.
- *
- * Returns:
- *\li #ISC_R_SUCCESS Success
- *\li #ISC_R_NOMEMORY Resource limit: Out of memory
- *\li #ISC_R_UNEXPECTED type was out of range and REQUIRE()
- * was disabled.
*/
isc_result_t
*\li The current duplicate filtering interval.
*/
-isc_result_t
+void
isc_log_settag(isc_logconfig_t *lcfg, const char *tag);
/*%<
* Set the program name or other identifier for #ISC_LOG_PRINTTAG.
* #ISC_LOG_PRINTTAG channel flag to not print anything. If tag equals the
* empty string, calls to isc_log_gettag will return NULL.
*
- * Returns:
- *\li #ISC_R_SUCCESS Success
- *\li #ISC_R_NOMEMORY Resource Limit: Out of memory
- *
* XXXDCL when creating a new isc_logconfig_t, it might be nice if the tag
* of the currently active isc_logconfig_t was inherited. this does not
* currently happen.
/*!
* Forward declarations.
*/
-static isc_result_t
+static void
assignchannel(isc_logconfig_t *lcfg, unsigned int category_id,
const isc_logmodule_t *module, isc_logchannel_t *channel);
-static isc_result_t
+static void
sync_channellist(isc_logconfig_t *lcfg);
static isc_result_t
/*
* Establish a new logging context, with default channels.
*/
-isc_result_t
+void
isc_log_create(isc_mem_t *mctx, isc_log_t **lctxp, isc_logconfig_t **lcfgp) {
isc_log_t *lctx;
isc_logconfig_t *lcfg = NULL;
- isc_result_t result;
REQUIRE(mctx != NULL);
REQUIRE(lctxp != NULL && *lctxp == NULL);
REQUIRE(lcfgp == NULL || *lcfgp == NULL);
lctx = isc_mem_get(mctx, sizeof(*lctx));
- if (lctx != NULL) {
- lctx->mctx = NULL;
- isc_mem_attach(mctx, &lctx->mctx);
- lctx->categories = NULL;
- lctx->category_count = 0;
- lctx->modules = NULL;
- lctx->module_count = 0;
- lctx->debug_level = 0;
+ lctx->mctx = NULL;
+ isc_mem_attach(mctx, &lctx->mctx);
+ lctx->categories = NULL;
+ lctx->category_count = 0;
+ lctx->modules = NULL;
+ lctx->module_count = 0;
+ lctx->debug_level = 0;
- ISC_LIST_INIT(lctx->messages);
+ ISC_LIST_INIT(lctx->messages);
- isc_mutex_init(&lctx->lock);
+ isc_mutex_init(&lctx->lock);
- /*
- * Normally setting the magic number is the last step done
- * in a creation function, but a valid log context is needed
- * by isc_log_registercategories and isc_logconfig_create.
- * If either fails, the lctx is destroyed and not returned
- * to the caller.
- */
- lctx->magic = LCTX_MAGIC;
+ /*
+ * Normally setting the magic number is the last step done
+ * in a creation function, but a valid log context is needed
+ * by isc_log_registercategories and isc_logconfig_create.
+ * If either fails, the lctx is destroyed and not returned
+ * to the caller.
+ */
+ lctx->magic = LCTX_MAGIC;
- isc_log_registercategories(lctx, isc_categories);
- isc_log_registermodules(lctx, isc_modules);
- result = isc_logconfig_create(lctx, &lcfg);
- } else {
- result = ISC_R_NOMEMORY;
- }
+ isc_log_registercategories(lctx, isc_categories);
+ isc_log_registermodules(lctx, isc_modules);
+ isc_logconfig_create(lctx, &lcfg);
- if (result == ISC_R_SUCCESS) {
- result = sync_channellist(lcfg);
- }
+ sync_channellist(lcfg);
- if (result == ISC_R_SUCCESS) {
- atomic_init(&lctx->logconfig, (uintptr_t)lcfg);
+ atomic_init(&lctx->logconfig, (uintptr_t)lcfg);
- *lctxp = lctx;
- if (lcfgp != NULL) {
- *lcfgp = lcfg;
- }
- } else {
- if (lcfg != NULL) {
- isc_logconfig_destroy(&lcfg);
- }
- if (lctx != NULL) {
- isc_log_destroy(&lctx);
- }
+ *lctxp = lctx;
+ if (lcfgp != NULL) {
+ *lcfgp = lcfg;
}
-
- return (result);
}
-isc_result_t
+void
isc_logconfig_create(isc_log_t *lctx, isc_logconfig_t **lcfgp) {
isc_logconfig_t *lcfg;
isc_logdestination_t destination;
- isc_result_t result = ISC_R_SUCCESS;
int level = ISC_LOG_INFO;
REQUIRE(lcfgp != NULL && *lcfgp == NULL);
* Create the default channels:
* default_syslog, default_stderr, default_debug and null.
*/
- if (result == ISC_R_SUCCESS) {
- destination.facility = LOG_DAEMON;
- result = isc_log_createchannel(lcfg, "default_syslog",
- ISC_LOG_TOSYSLOG, level,
- &destination, 0);
- }
+ destination.facility = LOG_DAEMON;
+ isc_log_createchannel(lcfg, "default_syslog", ISC_LOG_TOSYSLOG, level,
+ &destination, 0);
+
+ destination.file.stream = stderr;
+ destination.file.name = NULL;
+ destination.file.versions = ISC_LOG_ROLLNEVER;
+ destination.file.suffix = isc_log_rollsuffix_increment;
+ destination.file.maximum_size = 0;
+ isc_log_createchannel(lcfg, "default_stderr", ISC_LOG_TOFILEDESC, level,
+ &destination, ISC_LOG_PRINTTIME);
- if (result == ISC_R_SUCCESS) {
- destination.file.stream = stderr;
- destination.file.name = NULL;
- destination.file.versions = ISC_LOG_ROLLNEVER;
- destination.file.suffix = isc_log_rollsuffix_increment;
- destination.file.maximum_size = 0;
- result = isc_log_createchannel(lcfg, "default_stderr",
- ISC_LOG_TOFILEDESC, level,
- &destination, ISC_LOG_PRINTTIME);
- }
+ /*
+ * Set the default category's channel to default_stderr,
+ * which is at the head of the channels list because it was
+ * just created.
+ */
+ default_channel.channel = ISC_LIST_HEAD(lcfg->channels);
- if (result == ISC_R_SUCCESS) {
- /*
- * Set the default category's channel to default_stderr,
- * which is at the head of the channels list because it was
- * just created.
- */
- default_channel.channel = ISC_LIST_HEAD(lcfg->channels);
-
- destination.file.stream = stderr;
- destination.file.name = NULL;
- destination.file.versions = ISC_LOG_ROLLNEVER;
- destination.file.suffix = isc_log_rollsuffix_increment;
- destination.file.maximum_size = 0;
- result = isc_log_createchannel(
- lcfg, "default_debug", ISC_LOG_TOFILEDESC,
- ISC_LOG_DYNAMIC, &destination, ISC_LOG_PRINTTIME);
- }
+ destination.file.stream = stderr;
+ destination.file.name = NULL;
+ destination.file.versions = ISC_LOG_ROLLNEVER;
+ destination.file.suffix = isc_log_rollsuffix_increment;
+ destination.file.maximum_size = 0;
+ isc_log_createchannel(lcfg, "default_debug", ISC_LOG_TOFILEDESC,
+ ISC_LOG_DYNAMIC, &destination, ISC_LOG_PRINTTIME);
- if (result == ISC_R_SUCCESS) {
- result = isc_log_createchannel(lcfg, "null", ISC_LOG_TONULL,
- ISC_LOG_DYNAMIC, NULL, 0);
- }
+ isc_log_createchannel(lcfg, "null", ISC_LOG_TONULL, ISC_LOG_DYNAMIC,
+ NULL, 0);
- if (result == ISC_R_SUCCESS) {
- *lcfgp = lcfg;
- } else {
- isc_logconfig_destroy(&lcfg);
- }
-
- return (result);
+ *lcfgp = lcfg;
}
-isc_result_t
+void
isc_logconfig_use(isc_log_t *lctx, isc_logconfig_t *lcfg) {
isc_logconfig_t *old_cfg;
- isc_result_t result;
REQUIRE(VALID_CONTEXT(lctx));
REQUIRE(VALID_CONFIG(lcfg));
* They won't be equal if isc_log_usechannel has not been called
* since any call to isc_log_registercategories.
*/
- result = sync_channellist(lcfg);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
+ sync_channellist(lcfg);
old_cfg = (isc_logconfig_t *)atomic_exchange_acq_rel(&lctx->logconfig,
(uintptr_t)lcfg);
isc_logconfig_destroy(&old_cfg);
-
- return (ISC_R_SUCCESS);
}
void
return (NULL);
}
-isc_result_t
+void
isc_log_createchannel(isc_logconfig_t *lcfg, const char *name,
unsigned int type, int level,
const isc_logdestination_t *destination,
break;
default:
- isc_mem_free(mctx, channel->name);
- isc_mem_put(mctx, channel, sizeof(*channel));
- return (ISC_R_UNEXPECTED);
+ ISC_UNREACHABLE();
}
ISC_LIST_PREPEND(lcfg->channels, channel, link);
if (strcmp(name, "default_stderr") == 0) {
default_channel.channel = channel;
}
-
- return (ISC_R_SUCCESS);
}
isc_result_t
const isc_logmodule_t *module) {
isc_log_t *lctx;
isc_logchannel_t *channel;
- isc_result_t result = ISC_R_SUCCESS;
unsigned int i;
REQUIRE(VALID_CONFIG(lcfg));
}
if (category != NULL) {
- result = assignchannel(lcfg, category->id, module, channel);
+ assignchannel(lcfg, category->id, module, channel);
} else {
/*
* Assign to all categories. Note that this includes
* the default channel.
*/
for (i = 0; i < lctx->category_count; i++) {
- result = assignchannel(lcfg, i, module, channel);
- if (result != ISC_R_SUCCESS) {
- break;
- }
+ assignchannel(lcfg, i, module, channel);
}
}
- return (result);
+ return (ISC_R_SUCCESS);
}
void
return (lcfg->duplicate_interval);
}
-isc_result_t
+void
isc_log_settag(isc_logconfig_t *lcfg, const char *tag) {
REQUIRE(VALID_CONFIG(lcfg));
}
lcfg->tag = NULL;
}
-
- return (ISC_R_SUCCESS);
}
char *
**** Internal functions
****/
-static isc_result_t
+static void
assignchannel(isc_logconfig_t *lcfg, unsigned int category_id,
const isc_logmodule_t *module, isc_logchannel_t *channel) {
isc_logchannellist_t *new_item;
isc_log_t *lctx;
- isc_result_t result;
REQUIRE(VALID_CONFIG(lcfg));
/*
* Ensure lcfg->channellist_count == lctx->category_count.
*/
- result = sync_channellist(lcfg);
- if (result != ISC_R_SUCCESS) {
- return (result);
- }
+ sync_channellist(lcfg);
new_item = isc_mem_get(lctx->mctx, sizeof(*new_item));
lcfg->dynamic = true;
}
}
-
- return (ISC_R_SUCCESS);
}
/*
* This would ideally be part of isc_log_registercategories(), except then
* that function would have to return isc_result_t instead of void.
*/
-static isc_result_t
+static void
sync_channellist(isc_logconfig_t *lcfg) {
unsigned int bytes;
isc_log_t *lctx;
REQUIRE(lctx->category_count != 0);
if (lctx->category_count == lcfg->channellist_count) {
- return (ISC_R_SUCCESS);
+ return;
}
bytes = lctx->category_count * sizeof(ISC_LIST(isc_logchannellist_t));
lcfg->channellists = lists;
lcfg->channellist_count = lctx->category_count;
-
- return (ISC_R_SUCCESS);
}
static isc_result_t
size = sizeof(isc_logmessage_t) +
strlen(lctx->buffer) + 1;
message = isc_mem_get(lctx->mctx, size);
- {
- message->text = (char *)(message + 1);
- size -= sizeof(isc_logmessage_t);
- strlcpy(message->text, lctx->buffer,
- size);
- TIME_NOW(&message->time);
- ISC_LINK_INIT(message, link);
- ISC_LIST_APPEND(lctx->messages, message,
- link);
- }
+ message->text = (char *)(message + 1);
+ size -= sizeof(isc_logmessage_t);
+ strlcpy(message->text, lctx->buffer, size);
+ TIME_NOW(&message->time);
+ ISC_LINK_INIT(message, link);
+ ISC_LIST_APPEND(lctx->messages, message, link);
}
}
isc_logconfig_t *logconfig = NULL;
INSIST(test_lctx == NULL);
- CHECK(isc_log_create(test_mctx, &test_lctx, &logconfig));
-
+ isc_log_create(test_mctx, &test_lctx, &logconfig);
isc_log_registercategories(test_lctx, categories);
isc_log_setcontext(test_lctx);
destination.file.name = NULL;
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
- CHECK(isc_log_createchannel(logconfig, "stderr",
- ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC,
- &destination, 0));
+ isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
+ ISC_LOG_DYNAMIC, &destination, 0);
CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL));
}
isc_logdestination_t destination;
isc_logconfig_t *logconfig = NULL;
- CHECK(isc_log_create(mctx, &lctx, &logconfig));
+ isc_log_create(mctx, &lctx, &logconfig);
isc_log_registercategories(lctx, categories);
isc_log_setcontext(lctx);
destination.file.name = NULL;
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
- CHECK(isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
- ISC_LOG_DYNAMIC, &destination, 0));
+ isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
+ ISC_LOG_DYNAMIC, &destination, 0);
CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL));
return (ISC_R_SUCCESS);
isc_logdestination_t destination;
isc_logconfig_t *logconfig = NULL;
- CHECK(isc_log_create(mctx, &lctx, &logconfig));
+ isc_log_create(mctx, &lctx, &logconfig);
isc_log_registercategories(lctx, categories);
isc_log_setcontext(lctx);
destination.file.name = NULL;
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
- CHECK(isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
- ISC_LOG_DYNAMIC, &destination, 0));
+ isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
+ ISC_LOG_DYNAMIC, &destination, 0);
CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL));
return (ISC_R_SUCCESS);
isc_logconfig_t *logconfig = NULL;
INSIST(lctx == NULL);
- CHECK(isc_log_create(mctx, &lctx, &logconfig));
+ isc_log_create(mctx, &lctx, &logconfig);
isc_log_registercategories(lctx, categories);
isc_log_setcontext(lctx);
destination.file.name = NULL;
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
- CHECK(isc_log_createchannel(logconfig, "stderr",
- ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC,
- &destination, 0));
+ isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
+ ISC_LOG_DYNAMIC, &destination, 0);
CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL));
}