Lines Matching defs:log_control
162 struct log_control {
170 static struct log_control log_control = {
431 for (lindex = 0; lindex < log_control.log_nentries; lindex++) {
432 switch (log_control.log_entries[lindex].log_type) {
435 klog_rotate(&log_control.log_entries[lindex]);
440 if (fprintf(log_control.log_entries[lindex].lfu_filep, "%s\n",
444 log_control.log_entries[lindex].lfu_fname);
447 fflush(log_control.log_entries[lindex].lfu_filep);
455 if (DEVICE_PRINT(log_control.log_entries[lindex].ldu_filep,
459 log_control.log_entries[lindex].ldu_devname);
472 log_pri |= log_control.log_entries[lindex].lsu_facility;
474 log_pri = log_control.log_entries[lindex].lsu_facility |
475 log_control.log_entries[lindex].lsu_severity;
505 * log_control - List of entries (log_nentries long) which contains
541 log_control.log_nentries = 0;
551 for (log_control.log_nentries = 0;
552 logging_specs[log_control.log_nentries];
553 log_control.log_nentries++);
558 log_control.log_entries = (struct log_entry *)
559 malloc(log_control.log_nentries * sizeof(struct log_entry));
560 if (log_control.log_entries) {
564 for (i=0; i<log_control.log_nentries; i++) {
565 log_control.log_entries[i].log_type = K_LOG_NONE;
566 log_control.log_entries[i].log_2free = logging_specs[i];
586 log_control.log_entries[i].lfu_fopen_mode =
590 log_control.log_entries[i].lfu_fopen_mode);
595 log_control.log_entries[i].lfu_filep = f;
596 log_control.log_entries[i].log_type = K_LOG_FILE;
597 log_control.log_entries[i].lfu_fname = &cp[5];
598 log_control.log_entries[i].lfu_rotate_period =
600 log_control.log_entries[i].lfu_rotate_versions =
602 log_control.log_entries[i].lfu_last_rotated =
628 log_control.log_entries[i].lfu_rotate_period =
640 log_control.log_entries[i].lfu_rotate_versions = vers;
658 log_control.log_entries[i].lsu_facility = LOG_AUTH;
659 log_control.log_entries[i].lsu_severity = LOG_ERR;
678 log_control.log_entries[i].lsu_severity = LOG_ERR;
682 log_control.log_entries[i].lsu_severity =
688 log_control.log_entries[i].lsu_severity =
694 log_control.log_entries[i].lsu_severity = LOG_CRIT;
699 log_control.log_entries[i].lsu_severity =
705 log_control.log_entries[i].lsu_severity =
711 log_control.log_entries[i].lsu_severity = LOG_INFO;
716 log_control.log_entries[i].lsu_severity =
795 log_control.log_entries[i].lsu_facility = facilities[j].value;
803 log_control.log_entries[i].log_type = K_LOG_SYSLOG;
805 log_facility = log_control.log_entries[i].lsu_facility;
813 log_control.log_entries[i].lfu_filep =
815 if (log_control.log_entries[i].lfu_filep) {
816 log_control.log_entries[i].log_type = K_LOG_STDERR;
817 log_control.log_entries[i].lfu_fname =
825 log_control.log_entries[i].ldu_filep =
827 if (log_control.log_entries[i].ldu_filep) {
828 set_cloexec_file(log_control.log_entries[i].ldu_filep);
829 log_control.log_entries[i].log_type = K_LOG_CONSOLE;
830 log_control.log_entries[i].ldu_devname = "console";
841 log_control.log_entries[i].ldu_filep =
843 if (log_control.log_entries[i].ldu_filep) {
844 set_cloexec_file(log_control.log_entries[i].ldu_filep);
845 log_control.log_entries[i].log_type = K_LOG_DEVICE;
846 log_control.log_entries[i].ldu_devname = &cp[7];
853 if (log_control.log_entries[i].log_type == K_LOG_NONE) {
865 for (i=0; i<log_control.log_nentries; i++)
875 if (log_control.log_entries)
876 free(log_control.log_entries);
877 log_control.log_entries = &def_log_entry;
878 log_control.log_entries->log_type = K_LOG_SYSLOG;
879 log_control.log_entries->log_2free = (krb5_pointer) NULL;
880 log_facility = log_control.log_entries->lsu_facility = LOG_AUTH;
881 log_control.log_entries->lsu_severity = LOG_ERR;
883 log_control.log_nentries = 1;
885 if (log_control.log_nentries) {
886 log_control.log_whoami = strdup(whoami);
887 log_control.log_hostname = (char *) malloc(MAXHOSTNAMELEN + 1);
888 if (log_control.log_hostname) {
889 if (gethostname(log_control.log_hostname, MAXHOSTNAMELEN) == -1) {
890 free(log_control.log_hostname);
891 log_control.log_hostname = NULL;
893 log_control.log_hostname[MAXHOSTNAMELEN] = '\0';
898 log_control.log_opened = 1;
904 return((log_control.log_nentries) ? 0 : ENOENT);
915 for (lindex = 0; lindex < log_control.log_nentries; lindex++) {
916 switch (log_control.log_entries[lindex].log_type) {
922 fclose(log_control.log_entries[lindex].lfu_filep);
929 DEVICE_CLOSE(log_control.log_entries[lindex].ldu_filep);
941 if (log_control.log_entries[lindex].log_2free)
942 free(log_control.log_entries[lindex].log_2free);
944 if (log_control.log_entries != &def_log_entry)
945 free(log_control.log_entries);
946 log_control.log_entries = (struct log_entry *) NULL;
947 log_control.log_nentries = 0;
948 if (log_control.log_whoami)
949 free(log_control.log_whoami);
950 log_control.log_whoami = (char *) NULL;
951 if (log_control.log_hostname)
952 free(log_control.log_hostname);
953 log_control.log_hostname = (char *) NULL;
955 if (log_control.log_opened)
1070 log_control.log_hostname ? log_control.log_hostname : "",
1071 log_control.log_whoami ? log_control.log_whoami : "",
1087 if (log_control.log_nentries == 0) {
1097 for (lindex = 0; lindex < log_control.log_nentries; lindex++) {
1098 switch (log_control.log_entries[lindex].log_type) {
1101 klog_rotate(&log_control.log_entries[lindex]);
1106 if (fprintf(log_control.log_entries[lindex].lfu_filep, "%s\n",
1109 fprintf(stderr, log_file_err, log_control.log_whoami,
1110 log_control.log_entries[lindex].lfu_fname);
1113 fflush(log_control.log_entries[lindex].lfu_filep);
1121 if (DEVICE_PRINT(log_control.log_entries[lindex].ldu_filep,
1124 fprintf(stderr, log_device_err, log_control.log_whoami,
1125 log_control.log_entries[lindex].ldu_devname);
1174 for (lindex = 0; lindex < log_control.log_nentries; lindex++) {
1175 if (log_control.log_entries[lindex].log_type == K_LOG_FILE) {
1176 fclose(log_control.log_entries[lindex].lfu_filep);
1181 f = fopen(log_control.log_entries[lindex].lfu_fname, "a+F");
1184 log_control.log_entries[lindex].lfu_filep = f;
1188 log_control.log_entries[lindex].lfu_fname,
1245 for (lindex = 0; lindex < log_control.log_nentries; lindex++) {
1246 if (lindex != 0 && log_control.log_entries[lindex].log_type != K_LOG_NONE)
1248 switch (log_control.log_entries[lindex].log_type) {
1250 fprintf(stderr, "FILE=%s", log_control.log_entries[lindex].lfu_fname);
1259 fprintf(stderr, "DEVICE=%s", log_control.log_entries[lindex].ldu_devname);
1263 severity2string(log_control.log_entries[lindex].lsu_severity),
1264 facility2string(log_control.log_entries[lindex].lsu_facility));
1282 struct log_entry *tmp_log_entries = log_control.log_entries;
1285 if (log_control.log_entries != &def_log_entry) {
1286 log_control.log_entries = realloc(log_control.log_entries,
1287 (log_control.log_nentries + 1) * sizeof(struct log_entry));
1288 if (log_control.log_entries == NULL) {
1289 log_control.log_entries = tmp_log_entries;
1293 log_control.log_entries = malloc(2 * sizeof(struct log_entry));
1294 if (log_control.log_entries == NULL) {
1295 log_control.log_entries = &def_log_entry;
1298 (void) memcpy(&log_control.log_entries[0], &def_log_entry,
1302 i = log_control.log_nentries;
1303 if (log_control.log_entries[i].lfu_filep =
1305 log_control.log_entries[i].log_type = K_LOG_STDERR;
1306 log_control.log_entries[i].log_2free = NULL;
1307 log_control.log_entries[i].lfu_fname = "standard error";
1308 log_control.log_nentries++;
1312 tmp_log_entries = log_control.log_entries;
1313 log_control.log_entries = realloc(log_control.log_entries,
1314 (log_control.log_nentries) * sizeof(struct log_entry));
1315 if (log_control.log_entries == NULL)
1316 log_control.log_entries = tmp_log_entries;
1329 struct log_entry *tmp_log_entries = log_control.log_entries;
1333 for (i = 0; i < log_control.log_nentries; i++) {
1334 if (log_control.log_entries[i].log_type == K_LOG_STDERR) {
1339 if ( i < log_control.log_nentries) {
1340 for (; i < log_control.log_nentries - 1; i++)
1341 log_control.log_entries[i] =
1342 log_control.log_entries[i + 1];
1344 if (log_control.log_nentries > 1) {
1345 log_control.log_entries =
1346 realloc(log_control.log_entries,
1347 (log_control.log_nentries + 1) *
1349 if (log_control.log_entries != NULL)
1350 log_control.log_nentries--;
1352 log_control.log_entries = tmp_log_entries;
1354 if (log_control.log_entries != NULL)
1355 free(log_control.log_entries);
1365 for (i = 0; i < log_control.log_nentries; i++) {
1366 if (log_control.log_entries[i].log_type == K_LOG_STDERR) {