Lines Matching +full:channel +full:- +full:0

2  * Copyright (C) 2004-2007, 2009, 2011, 2012  Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1999-2003 Internet Software Consortium.
62 * This is the structure that holds each named channel. A simple linked
63 * list chains all of the channels together, so an individual channel is
93 isc_logchannel_t * channel; member
111 * about where messages are actually supposed to be sent -- the information
162 * Used when ISC_LOG_PRINTLEVEL is enabled for a channel.
195 { "default", 0 }, /* "default" must come first. */
196 { "general", 0 },
197 { NULL, 0 }
204 { "socket", 0 },
205 { "time", 0 },
206 { "interface", 0 },
207 { "timer", 0 },
208 { "file", 0 },
209 { NULL, 0 }
214 * because its channel member is pointed to a channel that is created
229 const isc_logmodule_t *module, isc_logchannel_t *channel);
235 greatest_version(isc_logchannel_t *channel, int *greatest);
238 roll_log(isc_logchannel_t *channel);
245 ISC_FORMAT_PRINTF(9, 0);
252 #define FACILITY(channel) (channel->destination.facility) argument
253 #define FILE_NAME(channel) (channel->destination.file.name) argument
254 #define FILE_STREAM(channel) (channel->destination.file.stream) argument
255 #define FILE_VERSIONS(channel) (channel->destination.file.versions) argument
256 #define FILE_MAXSIZE(channel) (channel->destination.file.maximum_size) argument
257 #define FILE_MAXREACHED(channel) (channel->destination.file.maximum_reached) argument
279 lctx->mctx = mctx; in isc_log_create()
280 lctx->categories = NULL; in isc_log_create()
281 lctx->category_count = 0; in isc_log_create()
282 lctx->modules = NULL; in isc_log_create()
283 lctx->module_count = 0; in isc_log_create()
284 lctx->debug_level = 0; in isc_log_create()
286 ISC_LIST_INIT(lctx->messages); in isc_log_create()
288 result = isc_mutex_init(&lctx->lock); in isc_log_create()
301 lctx->magic = LCTX_MAGIC; in isc_log_create()
314 lctx->logconfig = lcfg; in isc_log_create()
340 lcfg = isc_mem_get(lctx->mctx, sizeof(*lcfg)); in isc_logconfig_create()
343 lcfg->lctx = lctx; in isc_logconfig_create()
344 lcfg->channellists = NULL; in isc_logconfig_create()
345 lcfg->channellist_count = 0; in isc_logconfig_create()
346 lcfg->duplicate_interval = 0; in isc_logconfig_create()
347 lcfg->highest_level = level; in isc_logconfig_create()
348 lcfg->tag = NULL; in isc_logconfig_create()
349 lcfg->dynamic = ISC_FALSE; in isc_logconfig_create()
351 ISC_LIST_INIT(lcfg->channels); in isc_logconfig_create()
356 * config. If the channel creation fails, the lcfg is not in isc_logconfig_create()
359 lcfg->magic = LCFG_MAGIC; in isc_logconfig_create()
372 &destination, 0); in isc_logconfig_create()
379 destination.file.maximum_size = 0; in isc_logconfig_create()
389 * Set the default category's channel to default_stderr, in isc_logconfig_create()
393 default_channel.channel = ISC_LIST_HEAD(lcfg->channels); in isc_logconfig_create()
398 destination.file.maximum_size = 0; in isc_logconfig_create()
410 NULL, 0); in isc_logconfig_create()
426 ENSURE(lctx->logconfig != NULL); in isc_logconfig_get()
428 return (lctx->logconfig); in isc_logconfig_get()
438 REQUIRE(lcfg->lctx == lctx); in isc_logconfig_use()
441 * Ensure that lcfg->channellist_count == lctx->category_count. in isc_logconfig_use()
449 LOCK(&lctx->lock); in isc_logconfig_use()
451 old_cfg = lctx->logconfig; in isc_logconfig_use()
452 lctx->logconfig = lcfg; in isc_logconfig_use()
454 UNLOCK(&lctx->lock); in isc_logconfig_use()
471 mctx = lctx->mctx; in isc_log_destroy()
473 if (lctx->logconfig != NULL) { in isc_log_destroy()
474 lcfg = lctx->logconfig; in isc_log_destroy()
475 lctx->logconfig = NULL; in isc_log_destroy()
479 DESTROYLOCK(&lctx->lock); in isc_log_destroy()
481 while ((message = ISC_LIST_HEAD(lctx->messages)) != NULL) { in isc_log_destroy()
482 ISC_LIST_UNLINK(lctx->messages, message, link); in isc_log_destroy()
485 sizeof(*message) + strlen(message->text) + 1); in isc_log_destroy()
488 lctx->buffer[0] = '\0'; in isc_log_destroy()
489 lctx->debug_level = 0; in isc_log_destroy()
490 lctx->categories = NULL; in isc_log_destroy()
491 lctx->category_count = 0; in isc_log_destroy()
492 lctx->modules = NULL; in isc_log_destroy()
493 lctx->module_count = 0; in isc_log_destroy()
494 lctx->mctx = NULL; in isc_log_destroy()
495 lctx->magic = 0; in isc_log_destroy()
506 isc_logchannel_t *channel; in isc_logconfig_destroy() local
519 REQUIRE(lcfg->lctx != NULL && lcfg->lctx->logconfig != lcfg); in isc_logconfig_destroy()
521 mctx = lcfg->lctx->mctx; in isc_logconfig_destroy()
523 while ((channel = ISC_LIST_HEAD(lcfg->channels)) != NULL) { in isc_logconfig_destroy()
524 ISC_LIST_UNLINK(lcfg->channels, channel, link); in isc_logconfig_destroy()
526 if (channel->type == ISC_LOG_TOFILE) { in isc_logconfig_destroy()
528 * The filename for the channel may have ultimately in isc_logconfig_destroy()
529 * started its life in user-land as a const string, in isc_logconfig_destroy()
533 DE_CONST(FILE_NAME(channel), filename); in isc_logconfig_destroy()
536 if (FILE_STREAM(channel) != NULL) in isc_logconfig_destroy()
537 (void)fclose(FILE_STREAM(channel)); in isc_logconfig_destroy()
540 isc_mem_free(mctx, channel->name); in isc_logconfig_destroy()
541 isc_mem_put(mctx, channel, sizeof(*channel)); in isc_logconfig_destroy()
544 for (i = 0; i < lcfg->channellist_count; i++) in isc_logconfig_destroy()
545 while ((item = ISC_LIST_HEAD(lcfg->channellists[i])) != NULL) { in isc_logconfig_destroy()
546 ISC_LIST_UNLINK(lcfg->channellists[i], item, link); in isc_logconfig_destroy()
550 if (lcfg->channellist_count > 0) in isc_logconfig_destroy()
551 isc_mem_put(mctx, lcfg->channellists, in isc_logconfig_destroy()
552 lcfg->channellist_count * in isc_logconfig_destroy()
555 lcfg->dynamic = ISC_FALSE; in isc_logconfig_destroy()
556 if (lcfg->tag != NULL) in isc_logconfig_destroy()
557 isc_mem_free(lcfg->lctx->mctx, lcfg->tag); in isc_logconfig_destroy()
558 lcfg->tag = NULL; in isc_logconfig_destroy()
559 lcfg->highest_level = 0; in isc_logconfig_destroy()
560 lcfg->duplicate_interval = 0; in isc_logconfig_destroy()
561 lcfg->magic = 0; in isc_logconfig_destroy()
573 REQUIRE(categories != NULL && categories[0].name != NULL); in isc_log_registercategories()
583 if (lctx->categories == NULL) in isc_log_registercategories()
584 lctx->categories = categories; in isc_log_registercategories()
591 for (catp = lctx->categories; catp->name != NULL; ) in isc_log_registercategories()
592 if (catp->id == UINT_MAX) in isc_log_registercategories()
597 DE_CONST(catp->name, catp); in isc_log_registercategories()
601 catp->name = (void *)categories; in isc_log_registercategories()
602 catp->id = UINT_MAX; in isc_log_registercategories()
608 for (catp = categories; catp->name != NULL; catp++) in isc_log_registercategories()
609 catp->id = lctx->category_count++; in isc_log_registercategories()
619 for (catp = lctx->categories; catp->name != NULL; ) in isc_log_categorybyname()
620 if (catp->id == UINT_MAX) in isc_log_categorybyname()
625 DE_CONST(catp->name, catp); in isc_log_categorybyname()
627 if (strcmp(catp->name, name) == 0) in isc_log_categorybyname()
640 REQUIRE(modules != NULL && modules[0].name != NULL); in isc_log_registermodules()
650 if (lctx->modules == NULL) in isc_log_registermodules()
651 lctx->modules = modules; in isc_log_registermodules()
658 for (modp = lctx->modules; modp->name != NULL; ) in isc_log_registermodules()
659 if (modp->id == UINT_MAX) in isc_log_registermodules()
664 DE_CONST(modp->name, modp); in isc_log_registermodules()
668 modp->name = (void *)modules; in isc_log_registermodules()
669 modp->id = UINT_MAX; in isc_log_registermodules()
675 for (modp = modules; modp->name != NULL; modp++) in isc_log_registermodules()
676 modp->id = lctx->module_count++; in isc_log_registermodules()
686 for (modp = lctx->modules; modp->name != NULL; ) in isc_log_modulebyname()
687 if (modp->id == UINT_MAX) in isc_log_modulebyname()
692 DE_CONST(modp->name, modp); in isc_log_modulebyname()
694 if (strcmp(modp->name, name) == 0) in isc_log_modulebyname()
708 isc_logchannel_t *channel; in isc_log_createchannel() local
718 (unsigned int)~(ISC_LOG_PRINTALL | ISC_LOG_DEBUGONLY)) == 0); in isc_log_createchannel()
722 mctx = lcfg->lctx->mctx; in isc_log_createchannel()
724 channel = isc_mem_get(mctx, sizeof(*channel)); in isc_log_createchannel()
725 if (channel == NULL) in isc_log_createchannel()
728 channel->name = isc_mem_strdup(mctx, name); in isc_log_createchannel()
729 if (channel->name == NULL) { in isc_log_createchannel()
730 isc_mem_put(mctx, channel, sizeof(*channel)); in isc_log_createchannel()
734 channel->type = type; in isc_log_createchannel()
735 channel->level = level; in isc_log_createchannel()
736 channel->flags = flags; in isc_log_createchannel()
737 ISC_LINK_INIT(channel, link); in isc_log_createchannel()
741 FACILITY(channel) = destination->facility; in isc_log_createchannel()
750 FILE_NAME(channel) = in isc_log_createchannel()
751 isc_mem_strdup(mctx, destination->file.name); in isc_log_createchannel()
752 FILE_STREAM(channel) = NULL; in isc_log_createchannel()
753 FILE_VERSIONS(channel) = destination->file.versions; in isc_log_createchannel()
754 FILE_MAXSIZE(channel) = destination->file.maximum_size; in isc_log_createchannel()
755 FILE_MAXREACHED(channel) = ISC_FALSE; in isc_log_createchannel()
759 FILE_NAME(channel) = NULL; in isc_log_createchannel()
760 FILE_STREAM(channel) = destination->file.stream; in isc_log_createchannel()
761 FILE_MAXSIZE(channel) = 0; in isc_log_createchannel()
762 FILE_VERSIONS(channel) = ISC_LOG_ROLLNEVER; in isc_log_createchannel()
770 isc_mem_put(mctx, channel->name, strlen(channel->name) + 1); in isc_log_createchannel()
771 isc_mem_put(mctx, channel, sizeof(*channel)); in isc_log_createchannel()
775 ISC_LIST_PREPEND(lcfg->channels, channel, link); in isc_log_createchannel()
781 if (strcmp(name, "default_stderr") == 0) in isc_log_createchannel()
782 default_channel.channel = channel; in isc_log_createchannel()
793 isc_logchannel_t *channel; in isc_log_usechannel() local
800 lctx = lcfg->lctx; in isc_log_usechannel()
802 REQUIRE(category == NULL || category->id < lctx->category_count); in isc_log_usechannel()
803 REQUIRE(module == NULL || module->id < lctx->module_count); in isc_log_usechannel()
805 for (channel = ISC_LIST_HEAD(lcfg->channels); channel != NULL; in isc_log_usechannel()
806 channel = ISC_LIST_NEXT(channel, link)) in isc_log_usechannel()
807 if (strcmp(name, channel->name) == 0) in isc_log_usechannel()
810 if (channel == NULL) in isc_log_usechannel()
814 result = assignchannel(lcfg, category->id, module, channel); in isc_log_usechannel()
819 * the default channel. in isc_log_usechannel()
821 for (i = 0; i < lctx->category_count; i++) { in isc_log_usechannel()
822 result = assignchannel(lcfg, i, module, channel); in isc_log_usechannel()
842 NULL, 0, 0, format, args); in isc_log_write()
855 NULL, 0, 0, format, args); in isc_log_vwrite()
870 NULL, 0, 0, format, args); in isc_log_write1()
883 NULL, 0, 0, format, args); in isc_log_vwrite1()
955 isc_logchannel_t *channel; in isc_log_setdebuglevel() local
959 LOCK(&lctx->lock); in isc_log_setdebuglevel()
961 lctx->debug_level = level; in isc_log_setdebuglevel()
965 if (lctx->debug_level == 0) in isc_log_setdebuglevel()
966 for (channel = ISC_LIST_HEAD(lctx->logconfig->channels); in isc_log_setdebuglevel()
967 channel != NULL; in isc_log_setdebuglevel()
968 channel = ISC_LIST_NEXT(channel, link)) in isc_log_setdebuglevel()
969 if (channel->type == ISC_LOG_TOFILE && in isc_log_setdebuglevel()
970 (channel->flags & ISC_LOG_DEBUGONLY) != 0 && in isc_log_setdebuglevel()
971 FILE_STREAM(channel) != NULL) { in isc_log_setdebuglevel()
972 (void)fclose(FILE_STREAM(channel)); in isc_log_setdebuglevel()
973 FILE_STREAM(channel) = NULL; in isc_log_setdebuglevel()
975 UNLOCK(&lctx->lock); in isc_log_setdebuglevel()
982 return (lctx->debug_level); in isc_log_getdebuglevel()
989 lcfg->duplicate_interval = interval; in isc_log_setduplicateinterval()
996 return (lcfg->duplicate_interval); in isc_log_getduplicateinterval()
1003 if (tag != NULL && *tag != '\0') { in isc_log_settag()
1004 if (lcfg->tag != NULL) in isc_log_settag()
1005 isc_mem_free(lcfg->lctx->mctx, lcfg->tag); in isc_log_settag()
1006 lcfg->tag = isc_mem_strdup(lcfg->lctx->mctx, tag); in isc_log_settag()
1007 if (lcfg->tag == NULL) in isc_log_settag()
1011 if (lcfg->tag != NULL) in isc_log_settag()
1012 isc_mem_free(lcfg->lctx->mctx, lcfg->tag); in isc_log_settag()
1013 lcfg->tag = NULL; in isc_log_settag()
1023 return (lcfg->tag); in isc_log_gettag()
1026 /* XXXDCL NT -- This interface will assuredly be changing. */
1034 isc_logchannel_t *channel; in isc_log_closefilelogs() local
1038 LOCK(&lctx->lock); in isc_log_closefilelogs()
1039 for (channel = ISC_LIST_HEAD(lctx->logconfig->channels); in isc_log_closefilelogs()
1040 channel != NULL; in isc_log_closefilelogs()
1041 channel = ISC_LIST_NEXT(channel, link)) in isc_log_closefilelogs()
1043 if (channel->type == ISC_LOG_TOFILE && in isc_log_closefilelogs()
1044 FILE_STREAM(channel) != NULL) { in isc_log_closefilelogs()
1045 (void)fclose(FILE_STREAM(channel)); in isc_log_closefilelogs()
1046 FILE_STREAM(channel) = NULL; in isc_log_closefilelogs()
1048 UNLOCK(&lctx->lock); in isc_log_closefilelogs()
1057 const isc_logmodule_t *module, isc_logchannel_t *channel) in assignchannel() argument
1065 lctx = lcfg->lctx; in assignchannel()
1067 REQUIRE(category_id < lctx->category_count); in assignchannel()
1068 REQUIRE(module == NULL || module->id < lctx->module_count); in assignchannel()
1069 REQUIRE(channel != NULL); in assignchannel()
1072 * Ensure lcfg->channellist_count == lctx->category_count. in assignchannel()
1078 new_item = isc_mem_get(lctx->mctx, sizeof(*new_item)); in assignchannel()
1082 new_item->channel = channel; in assignchannel()
1083 new_item->module = module; in assignchannel()
1084 ISC_LIST_INITANDPREPEND(lcfg->channellists[category_id], in assignchannel()
1088 * Remember the highest logging level set by any channel in the in assignchannel()
1090 * message is too high to be logged by any channel. in assignchannel()
1092 if (channel->type != ISC_LOG_TONULL) { in assignchannel()
1093 if (lcfg->highest_level < channel->level) in assignchannel()
1094 lcfg->highest_level = channel->level; in assignchannel()
1095 if (channel->level == ISC_LOG_DYNAMIC) in assignchannel()
1096 lcfg->dynamic = ISC_TRUE; in assignchannel()
1114 lctx = lcfg->lctx; in sync_channellist()
1116 REQUIRE(lctx->category_count != 0); in sync_channellist()
1118 if (lctx->category_count == lcfg->channellist_count) in sync_channellist()
1121 bytes = lctx->category_count * sizeof(ISC_LIST(isc_logchannellist_t)); in sync_channellist()
1123 lists = isc_mem_get(lctx->mctx, bytes); in sync_channellist()
1128 memset(lists, 0, bytes); in sync_channellist()
1130 if (lcfg->channellist_count != 0) { in sync_channellist()
1131 bytes = lcfg->channellist_count * in sync_channellist()
1133 memcpy(lists, lcfg->channellists, bytes); in sync_channellist()
1134 isc_mem_put(lctx->mctx, lcfg->channellists, bytes); in sync_channellist()
1137 lcfg->channellists = lists; in sync_channellist()
1138 lcfg->channellist_count = lctx->category_count; in sync_channellist()
1144 greatest_version(isc_logchannel_t *channel, int *greatestp) { in greatest_version() argument
1148 int version, greatest = -1; in greatest_version()
1157 REQUIRE(channel->type == ISC_LOG_TOFILE); in greatest_version()
1163 basenam = strrchr(FILE_NAME(channel), sep); in greatest_version()
1165 basename2 = strrchr(FILE_NAME(channel), '\\'); in greatest_version()
1173 *basenam++ = '\0'; in greatest_version()
1174 dirname = FILE_NAME(channel); in greatest_version()
1176 DE_CONST(FILE_NAME(channel), basenam); in greatest_version()
1187 if (basenam != FILE_NAME(channel)) in greatest_version()
1188 *(basenam - 1) = sep; in greatest_version()
1198 strncmp(dir.entry.name, basenam, basenamelen) == 0 && in greatest_version()
1203 if (*digit_end == '\0' && version > greatest) in greatest_version()
1215 roll_log(isc_logchannel_t *channel) { in roll_log() argument
1227 if (FILE_VERSIONS(channel) == ISC_LOG_ROLLNEVER) in roll_log()
1230 path = FILE_NAME(channel); in roll_log()
1235 * though the file names are 0 based, so an oldest log of log.1 in roll_log()
1238 result = greatest_version(channel, &greatest); in roll_log()
1244 * Since the highest number is one less than FILE_VERSIONS(channel) in roll_log()
1246 * decremented when it is equal to -- or greater than -- in roll_log()
1247 * FILE_VERSIONS(channel). When greatest is less than in roll_log()
1248 * FILE_VERSIONS(channel), it is already suitable for use as in roll_log()
1252 if (FILE_VERSIONS(channel) == ISC_LOG_ROLLINFINITE || in roll_log()
1253 FILE_VERSIONS(channel) > greatest) in roll_log()
1257 * When greatest is >= FILE_VERSIONS(channel), it needs to in roll_log()
1258 * be reduced until it is FILE_VERSIONS(channel) - 1. in roll_log()
1261 while (--greatest >= FILE_VERSIONS(channel)) { in roll_log()
1264 if (n >= (int)sizeof(current) || n < 0) in roll_log()
1276 for (i = greatest; i > 0; i--) { in roll_log()
1278 n = snprintf(current, sizeof(current), "%s.%d", path, i - 1); in roll_log()
1279 if (n >= (int)sizeof(current) || n < 0) in roll_log()
1283 if (n >= (int)sizeof(new) || n < 0) in roll_log()
1292 "'%s.%d': %s", path, i - 1, path, i, in roll_log()
1296 if (FILE_VERSIONS(channel) != 0) { in roll_log()
1297 n = snprintf(new, sizeof(new), "%s.0", path); in roll_log()
1298 if (n >= (int)sizeof(new) || n < 0) in roll_log()
1305 "unable to rename log file '%s' to '%s.0': %s", in roll_log()
1319 isc_log_open(isc_logchannel_t *channel) { in isc_log_open() argument
1326 REQUIRE(channel->type == ISC_LOG_TOFILE); in isc_log_open()
1327 REQUIRE(FILE_STREAM(channel) == NULL); in isc_log_open()
1329 path = FILE_NAME(channel); in isc_log_open()
1331 REQUIRE(path != NULL && *path != '\0'); in isc_log_open()
1338 if (stat(path, &statbuf) == 0) { in isc_log_open()
1341 if ((FILE_MAXSIZE(channel) == 0 && in isc_log_open()
1342 FILE_VERSIONS(channel) != ISC_LOG_ROLLNEVER) || in isc_log_open()
1343 (FILE_MAXSIZE(channel) > 0 && in isc_log_open()
1344 statbuf.st_size >= FILE_MAXSIZE(channel))) in isc_log_open()
1356 if (FILE_VERSIONS(channel) == ISC_LOG_ROLLNEVER) in isc_log_open()
1358 result = roll_log(channel); in isc_log_open()
1360 if ((channel->flags & ISC_LOG_OPENERR) == 0) { in isc_log_open()
1364 FILE_NAME(channel), in isc_log_open()
1366 channel->flags |= ISC_LOG_OPENERR; in isc_log_open()
1372 result = isc_stdio_open(path, "a", &FILE_STREAM(channel)); in isc_log_open()
1381 * possibly be logged to any channels -- primarily debugging in isc_log_wouldlog()
1385 * highest_level, or if there is a dynamic channel and the level is in isc_log_wouldlog()
1396 if (lctx == NULL || lctx->logconfig == NULL) in isc_log_wouldlog()
1399 return (ISC_TF(level <= lctx->logconfig->highest_level || in isc_log_wouldlog()
1400 (lctx->logconfig->dynamic && in isc_log_wouldlog()
1401 level <= lctx->debug_level))); in isc_log_wouldlog()
1420 isc_logchannel_t *channel; in isc_log_doit() local
1433 * be non-existent. in isc_log_doit()
1438 REQUIRE(category->id < lctx->category_count); in isc_log_doit()
1439 REQUIRE(module->id < lctx->module_count); in isc_log_doit()
1449 time_string[0] = '\0'; in isc_log_doit()
1450 level_string[0] = '\0'; in isc_log_doit()
1452 LOCK(&lctx->lock); in isc_log_doit()
1454 lctx->buffer[0] = '\0'; in isc_log_doit()
1456 lcfg = lctx->logconfig; in isc_log_doit()
1458 category_channels = ISC_LIST_HEAD(lcfg->channellists[category->id]); in isc_log_doit()
1466 * If the channel list end was reached and a match was made, in isc_log_doit()
1473 category_channels != ISC_LIST_HEAD(lcfg->channellists[0])) in isc_log_doit()
1479 ISC_LIST_HEAD(lcfg->channellists[0]); in isc_log_doit()
1485 * default channel. in isc_log_doit()
1489 if (category_channels->module != NULL && in isc_log_doit()
1490 category_channels->module != module) { in isc_log_doit()
1498 channel = category_channels->channel; in isc_log_doit()
1501 if (((channel->flags & ISC_LOG_DEBUGONLY) != 0) && in isc_log_doit()
1502 lctx->debug_level == 0) in isc_log_doit()
1505 if (channel->level == ISC_LOG_DYNAMIC) { in isc_log_doit()
1506 if (lctx->debug_level < level) in isc_log_doit()
1508 } else if (channel->level < level) in isc_log_doit()
1511 if ((channel->flags & ISC_LOG_PRINTTIME) != 0 && in isc_log_doit()
1512 time_string[0] == '\0') { in isc_log_doit()
1520 if ((channel->flags & ISC_LOG_PRINTLEVEL) != 0 && in isc_log_doit()
1521 level_string[0] == '\0') { in isc_log_doit()
1532 "%s %d: ", log_level_strings[0], in isc_log_doit()
1536 "%s: ", log_level_strings[-level]); in isc_log_doit()
1542 if (lctx->buffer[0] == '\0') { in isc_log_doit()
1543 (void)vsnprintf(lctx->buffer, sizeof(lctx->buffer), in isc_log_doit()
1555 lcfg->duplicate_interval, 0); in isc_log_doit()
1571 message =ISC_LIST_HEAD(lctx->messages); in isc_log_doit()
1574 if (isc_time_compare(&message->time, in isc_log_doit()
1575 &oldest) < 0) { in isc_log_doit()
1591 ISC_LIST_UNLINK(lctx->messages, in isc_log_doit()
1594 isc_mem_put(lctx->mctx, in isc_log_doit()
1597 strlen(message->text)); in isc_log_doit()
1607 if (strcmp(lctx->buffer, message->text) in isc_log_doit()
1608 == 0) { in isc_log_doit()
1614 UNLOCK(&lctx->lock); in isc_log_doit()
1625 octets = strlen(lctx->buffer) + 1; in isc_log_doit()
1626 new = isc_mem_get(lctx->mctx, in isc_log_doit()
1634 new->text = (char *)(new + 1); in isc_log_doit()
1635 strlcpy(new->text, lctx->buffer, octets); in isc_log_doit()
1637 TIME_NOW(&new->time); in isc_log_doit()
1639 ISC_LIST_APPEND(lctx->messages, in isc_log_doit()
1645 printtime = ISC_TF((channel->flags & ISC_LOG_PRINTTIME) in isc_log_doit()
1646 != 0); in isc_log_doit()
1647 printtag = ISC_TF((channel->flags & ISC_LOG_PRINTTAG) in isc_log_doit()
1648 != 0 && lcfg->tag != NULL); in isc_log_doit()
1649 printcategory = ISC_TF((channel->flags & ISC_LOG_PRINTCATEGORY) in isc_log_doit()
1650 != 0); in isc_log_doit()
1651 printmodule = ISC_TF((channel->flags & ISC_LOG_PRINTMODULE) in isc_log_doit()
1652 != 0); in isc_log_doit()
1653 printlevel = ISC_TF((channel->flags & ISC_LOG_PRINTLEVEL) in isc_log_doit()
1654 != 0); in isc_log_doit()
1656 switch (channel->type) { in isc_log_doit()
1658 if (FILE_MAXREACHED(channel)) { in isc_log_doit()
1668 if (FILE_VERSIONS(channel) != in isc_log_doit()
1670 (stat(FILE_NAME(channel), &statbuf) != 0 && in isc_log_doit()
1672 statbuf.st_size < FILE_MAXSIZE(channel)) { in isc_log_doit()
1673 (void)fclose(FILE_STREAM(channel)); in isc_log_doit()
1674 FILE_STREAM(channel) = NULL; in isc_log_doit()
1675 FILE_MAXREACHED(channel) = ISC_FALSE; in isc_log_doit()
1683 if (FILE_STREAM(channel) == NULL) { in isc_log_doit()
1684 result = isc_log_open(channel); in isc_log_doit()
1687 (channel->flags & ISC_LOG_OPENERR) == 0) { in isc_log_doit()
1690 FILE_NAME(channel), in isc_log_doit()
1692 channel->flags |= ISC_LOG_OPENERR; in isc_log_doit()
1696 channel->flags &= ~ISC_LOG_OPENERR; in isc_log_doit()
1701 fprintf(FILE_STREAM(channel), "%s%s%s%s%s%s%s%s%s%s\n", in isc_log_doit()
1704 printtag ? lcfg->tag : "", in isc_log_doit()
1706 printcategory ? category->name : "", in isc_log_doit()
1708 printmodule ? (module != NULL ? module->name in isc_log_doit()
1713 lctx->buffer); in isc_log_doit()
1715 fflush(FILE_STREAM(channel)); in isc_log_doit()
1722 if (FILE_MAXSIZE(channel) > 0) { in isc_log_doit()
1723 INSIST(channel->type == ISC_LOG_TOFILE); in isc_log_doit()
1727 if (fstat(fileno(FILE_STREAM(channel)), in isc_log_doit()
1728 &statbuf) >= 0 && in isc_log_doit()
1729 statbuf.st_size > FILE_MAXSIZE(channel)) in isc_log_doit()
1730 FILE_MAXREACHED(channel) = ISC_TRUE; in isc_log_doit()
1736 if (level > 0) in isc_log_doit()
1741 syslog_level = syslog_map[-level]; in isc_log_doit()
1743 (void)syslog(FACILITY(channel) | syslog_level, in isc_log_doit()
1747 printtag ? lcfg->tag : "", in isc_log_doit()
1749 printcategory ? category->name : "", in isc_log_doit()
1751 printmodule ? (module != NULL ? module->name in isc_log_doit()
1756 lctx->buffer); in isc_log_doit()
1766 UNLOCK(&lctx->lock); in isc_log_doit()