Lines Matching refs:chan

59 version_rename(log_channel chan) {
64 ver = chan->out.file.versions;
72 if (strlen(chan->out.file.name) > (size_t)(PATH_MAX-3))
75 sprintf(old_name, "%s.%d", chan->out.file.name, ver-1);
76 sprintf(new_name, "%s.%d", chan->out.file.name, ver);
79 sprintf(new_name, "%s.0", chan->out.file.name);
80 (void)isc_movefile(chan->out.file.name, new_name);
84 log_open_stream(log_channel chan) {
90 if (chan == NULL || chan->type != log_file) {
98 if (chan->out.file.stream != NULL)
99 return (chan->out.file.stream);
101 if (stat(chan->out.file.name, &sb) < 0) {
105 chan->out.file.name, strerror(errno));
106 chan->flags |= LOG_CHANNEL_BROKEN;
113 if (chan->out.file.versions) {
117 chan->out.file.name);
118 chan->flags |= LOG_CHANNEL_BROKEN;
126 if ((chan->flags & LOG_TRUNCATE) != 0) {
128 (void)unlink(chan->out.file.name);
133 chan->out.file.name);
134 chan->flags |= LOG_CHANNEL_BROKEN;
140 fd = open(chan->out.file.name, flags,
144 chan->out.file.name, strerror(errno));
145 chan->flags |= LOG_CHANNEL_BROKEN;
151 chan->flags |= LOG_CHANNEL_BROKEN;
154 (void) fchown(fd, chan->out.file.owner, chan->out.file.group);
156 chan->out.file.stream = stream;
161 log_close_stream(log_channel chan) {
164 if (chan == NULL || chan->type != log_file) {
168 stream = chan->out.file.stream;
169 chan->out.file.stream = NULL;
189 log_get_stream(log_channel chan) {
190 if (chan == NULL || chan->type != log_file) {
194 return (chan->out.file.stream);
198 log_get_filename(log_channel chan) {
199 if (chan == NULL || chan->type != log_file) {
203 return (chan->out.file.name);
207 log_check_channel(log_context lc, int level, log_channel chan) {
220 if ((chan->flags & (LOG_CHANNEL_BROKEN|LOG_CHANNEL_OFF)) != 0)
224 if ((chan->flags & LOG_REQUIRE_DEBUG) && !debugging)
228 if ((chan->flags & LOG_USE_CONTEXT_LEVEL) != 0) {
231 chan_level = chan->level;
276 log_channel chan;
354 chan = lcl->channel;
356 if (!log_check_channel(lc, level, chan))
369 switch (chan->type) {
375 syslog(chan->out.facility|syslog_priority[pri],
377 (chan->flags & LOG_TIMESTAMP) ? time_buf : "",
378 (chan->flags & LOG_PRINT_CATEGORY) ?
380 (chan->flags & LOG_PRINT_LEVEL) ?
385 stream = chan->out.file.stream;
387 stream = log_open_stream(chan);
391 if (chan->out.file.max_size != ULONG_MAX) {
397 chan->out.file.max_size) {
404 log_close_stream(chan);
405 version_rename(chan);
406 stream = log_open_stream(chan);
412 (chan->flags & LOG_TIMESTAMP) ? time_buf : "",
413 (chan->flags & LOG_PRINT_CATEGORY) ?
415 (chan->flags & LOG_PRINT_LEVEL) ?
470 log_channel chan;
478 chan = lcl->channel;
479 (void)log_free_channel(chan);
488 log_add_channel(log_context lc, int category, log_channel chan) {
501 lcl->channel = chan;
504 chan->references++;
509 log_remove_channel(log_context lc, int category, log_channel chan) {
522 if (lcl->channel == chan) {
523 log_free_channel(chan);
581 log_channel chan;
583 chan = memget(sizeof (struct log_channel));
584 if (chan == NULL) {
588 chan->type = log_syslog;
589 chan->flags = flags;
590 chan->level = level;
591 chan->out.facility = facility;
592 chan->references = 0;
593 return (chan);
600 log_channel chan;
602 chan = memget(sizeof (struct log_channel));
603 if (chan == NULL) {
607 chan->type = log_file;
608 chan->flags = flags;
609 chan->level = level;
619 chan->out.file.name_size = ((len / 256) + 1) * 256;
620 chan->out.file.name = memget(chan->out.file.name_size);
621 if (chan->out.file.name == NULL) {
622 memput(chan, sizeof (struct log_channel));
627 strcpy(chan->out.file.name, name);
629 chan->out.file.name_size = 0;
630 chan->out.file.name = NULL;
632 chan->out.file.stream = stream;
633 chan->out.file.versions = versions;
634 chan->out.file.max_size = max_size;
635 chan->out.file.owner = getuid();
636 chan->out.file.group = getgid();
637 chan->references = 0;
638 return (chan);
642 log_set_file_owner(log_channel chan, uid_t owner, gid_t group) {
643 if (chan->type != log_file) {
647 chan->out.file.owner = owner;
648 chan->out.file.group = group;
654 log_channel chan;
656 chan = memget(sizeof (struct log_channel));
657 if (chan == NULL) {
661 chan->type = log_null;
662 chan->flags = LOG_CHANNEL_OFF;
663 chan->level = log_info;
664 chan->references = 0;
665 return (chan);
669 log_inc_references(log_channel chan) {
670 if (chan == NULL) {
674 chan->references++;
679 log_dec_references(log_channel chan) {
680 if (chan == NULL || chan->references <= 0) {
684 chan->references--;
689 log_get_channel_type(log_channel chan) {
690 REQUIRE(chan != NULL);
692 return (chan->type);
696 log_free_channel(log_channel chan) {
697 if (chan == NULL || chan->references <= 0) {
701 chan->references--;
702 if (chan->references == 0) {
703 if (chan->type == log_file) {
704 if ((chan->flags & LOG_CLOSE_STREAM) &&
705 chan->out.file.stream != NULL)
706 (void)fclose(chan->out.file.stream);
707 if (chan->out.file.name != NULL)
708 memput(chan->out.file.name,
709 chan->out.file.name_size);
711 memput(chan, sizeof (struct log_channel));