Lines Matching defs:lctx

43 #define VALID_CONTEXT(lctx) ISC_MAGIC_VALID(lctx, LCTX_MAGIC)
112 isc_log_t *lctx;
217 sync_highest_level(isc_log_t *lctx, isc_logconfig_t *lcfg);
223 isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
250 isc_log_t *lctx;
257 lctx = isc_mem_get(mctx, sizeof(*lctx));
262 * If either fails, the lctx is destroyed and not returned
265 *lctx = (isc_log_t){
270 isc_mem_attach(mctx, &lctx->mctx);
271 isc_mutex_init(&lctx->lock);
272 isc_log_registercategories(lctx, isc_categories);
273 isc_log_registermodules(lctx, isc_modules);
274 isc_logconfig_create(lctx, &lcfg);
277 lctx->logconfig = lcfg;
279 atomic_init(&lctx->highest_level, lcfg->highest_level);
280 atomic_init(&lctx->dynamic, lcfg->dynamic);
282 *lctxp = lctx;
287 isc_logconfig_create(isc_log_t *lctx, isc_logconfig_t **lcfgp) {
293 REQUIRE(VALID_CONTEXT(lctx));
295 lcfg = isc_mem_get(lctx->mctx, sizeof(*lcfg));
299 .lctx = lctx,
342 isc_logconfig_use(isc_log_t *lctx, isc_logconfig_t *lcfg) {
345 REQUIRE(VALID_CONTEXT(lctx));
347 REQUIRE(lcfg->lctx == lctx);
350 * Ensure that lcfg->channellist_count == lctx->category_count.
356 old_cfg = rcu_xchg_pointer(&lctx->logconfig, lcfg);
357 sync_highest_level(lctx, lcfg);
365 isc_log_t *lctx;
372 lctx = *lctxp;
374 mctx = lctx->mctx;
377 atomic_store_release(&lctx->debug_level, 0);
378 atomic_store_release(&lctx->highest_level, 0);
379 atomic_store_release(&lctx->dynamic, false);
381 lcfg = rcu_xchg_pointer(&lctx->logconfig, NULL);
388 isc_mutex_destroy(&lctx->lock);
390 while ((message = ISC_LIST_HEAD(lctx->messages)) != NULL) {
391 ISC_LIST_UNLINK(lctx->messages, message, link);
397 lctx->buffer[0] = '\0';
398 lctx->categories = NULL;
399 lctx->category_count = 0;
400 lctx->modules = NULL;
401 lctx->module_count = 0;
402 lctx->mctx = NULL;
403 lctx->magic = 0;
405 isc_mem_putanddetach(&mctx, lctx, sizeof(*lctx));
425 REQUIRE(lcfg->lctx != NULL);
428 REQUIRE(rcu_dereference(lcfg->lctx->logconfig) != lcfg);
431 mctx = lcfg->lctx->mctx;
470 isc_mem_free(lcfg->lctx->mctx, lcfg->tag);
481 isc_log_registercategories(isc_log_t *lctx, isc_logcategory_t categories[]) {
484 REQUIRE(VALID_CONTEXT(lctx));
495 if (lctx->categories == NULL) {
496 lctx->categories = categories;
502 for (catp = lctx->categories; catp->name != NULL;) {
522 catp->id = lctx->category_count++;
527 isc_log_categorybyname(isc_log_t *lctx, const char *name) {
530 REQUIRE(VALID_CONTEXT(lctx));
533 for (catp = lctx->categories; catp->name != NULL;) {
552 isc_log_registermodules(isc_log_t *lctx, isc_logmodule_t modules[]) {
555 REQUIRE(VALID_CONTEXT(lctx));
566 if (lctx->modules == NULL) {
567 lctx->modules = modules;
573 for (modp = lctx->modules; modp->name != NULL;) {
593 modp->id = lctx->module_count++;
598 isc_log_modulebyname(isc_log_t *lctx, const char *name) {
601 REQUIRE(VALID_CONTEXT(lctx));
604 for (modp = lctx->modules; modp->name != NULL;) {
643 mctx = lcfg->lctx->mctx;
705 isc_log_t *lctx;
711 lctx = lcfg->lctx;
713 REQUIRE(category == NULL || category->id < lctx->category_count);
714 REQUIRE(module == NULL || module->id < lctx->module_count);
735 for (size_t i = 0; i < lctx->category_count; i++) {
744 if (rcu_dereference(lcfg->lctx->logconfig) == lcfg) {
745 sync_highest_level(lctx, lcfg);
753 isc_log_write(isc_log_t *lctx, isc_logcategory_t *category,
762 isc_log_doit(lctx, category, module, level, false, format, args);
767 isc_log_vwrite(isc_log_t *lctx, isc_logcategory_t *category,
773 isc_log_doit(lctx, category, module, level, false, format, args);
777 isc_log_write1(isc_log_t *lctx, isc_logcategory_t *category,
786 isc_log_doit(lctx, category, module, level, true, format, args);
791 isc_log_vwrite1(isc_log_t *lctx, isc_logcategory_t *category,
797 isc_log_doit(lctx, category, module, level, true, format, args);
801 isc_log_setcontext(isc_log_t *lctx) {
802 isc_lctx = lctx;
806 isc_log_setdebuglevel(isc_log_t *lctx, unsigned int level) {
807 REQUIRE(VALID_CONTEXT(lctx));
809 atomic_store_release(&lctx->debug_level, level);
815 isc_logconfig_t *lcfg = rcu_dereference(lctx->logconfig);
817 LOCK(&lctx->lock);
831 UNLOCK(&lctx->lock);
838 isc_log_getdebuglevel(isc_log_t *lctx) {
839 REQUIRE(VALID_CONTEXT(lctx));
841 return atomic_load_acquire(&lctx->debug_level);
864 isc_mem_free(lcfg->lctx->mctx, lcfg->tag);
866 lcfg->tag = isc_mem_strdup(lcfg->lctx->mctx, tag);
869 isc_mem_free(lcfg->lctx->mctx, lcfg->tag);
889 isc_log_closefilelogs(isc_log_t *lctx) {
890 REQUIRE(VALID_CONTEXT(lctx));
893 isc_logconfig_t *lcfg = rcu_dereference(lctx->logconfig);
895 LOCK(&lctx->lock);
906 UNLOCK(&lctx->lock);
919 isc_log_t *lctx;
923 lctx = lcfg->lctx;
925 REQUIRE(category_id < lctx->category_count);
926 REQUIRE(module == NULL || module->id < lctx->module_count);
930 * Ensure lcfg->channellist_count == lctx->category_count.
934 new_item = isc_mem_get(lctx->mctx, sizeof(*new_item));
964 isc_log_t *lctx = lcfg->lctx;
966 REQUIRE(lctx->category_count != 0);
968 if (lctx->category_count == lcfg->channellist_count) {
973 lctx->mctx, lcfg->channellists, lcfg->channellist_count,
974 lctx->category_count, sizeof(ISC_LIST(isc_logchannellist_t)));
976 lcfg->channellist_count = lctx->category_count;
980 sync_highest_level(isc_log_t *lctx, isc_logconfig_t *lcfg) {
981 atomic_store(&lctx->highest_level, lcfg->highest_level);
982 atomic_store(&lctx->dynamic, lcfg->dynamic);
1437 isc_log_wouldlog(isc_log_t *lctx, int level) {
1448 if (lctx == NULL) {
1455 int highest_level = atomic_load_acquire(&lctx->highest_level);
1459 if (atomic_load_acquire(&lctx->dynamic)) {
1460 int debug_level = atomic_load_acquire(&lctx->debug_level);
1470 isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
1488 REQUIRE(lctx == NULL || VALID_CONTEXT(lctx));
1499 if (lctx == NULL) {
1503 REQUIRE(category->id < lctx->category_count);
1504 REQUIRE(module->id < lctx->module_count);
1506 if (!isc_log_wouldlog(lctx, level)) {
1515 LOCK(&lctx->lock);
1517 lctx->buffer[0] = '\0';
1519 isc_logconfig_t *lcfg = rcu_dereference(lctx->logconfig);
1573 dlevel = atomic_load_acquire(&lctx->debug_level);
1623 if (lctx->buffer[0] == '\0') {
1624 (void)vsnprintf(lctx->buffer, sizeof(lctx->buffer),
1655 message = ISC_LIST_HEAD(lctx->messages);
1680 ISC_LIST_UNLINK(lctx->messages,
1684 lctx->mctx, message,
1697 if (strcmp(lctx->buffer,
1717 strlen(lctx->buffer) + 1;
1718 message = isc_mem_get(lctx->mctx, size);
1721 strlcpy(message->text, lctx->buffer, size);
1724 ISC_LIST_APPEND(lctx->messages, message, link);
1816 printlevel ? level_string : "", lctx->buffer);
1863 printlevel ? level_string : "", lctx->buffer);
1872 UNLOCK(&lctx->lock);