MCPcopy Create free account
hub / github.com/corosync/corosync / logsys_format_set

Function logsys_format_set

exec/logsys.c:571–628  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

569}
570
571int logsys_format_set (const char *format)
572{
573 int i;
574 int c;
575 int w;
576 int reminder;
577 char syslog_format[128];
578 char file_format[128];
579
580 if (format_buffer) {
581 free(format_buffer);
582 format_buffer = NULL;
583 }
584
585 format_buffer = strdup(format ? format : "%7p [%6g] %b");
586 if (format_buffer == NULL) {
587 return -1;
588 }
589
590 qb_log_format_set(QB_LOG_STDERR, format_buffer);
591
592 logsys_file_format_get(file_format, 128);
593 for (i = 0; i <= LOGSYS_MAX_SUBSYS_COUNT; i++) {
594 if (logsys_loggers[i].target_id > 0) {
595 qb_log_format_set(logsys_loggers[i].target_id, file_format);
596 }
597 }
598
599 /*
600 * This just goes through and remove %t, %T and %p from
601 * the format string for syslog.
602 */
603 w = 0;
604 memset(syslog_format, '\0', sizeof(syslog_format));
605 for (c = 0; c < strlen(format_buffer); c++) {
606 if (format_buffer[c] == '%') {
607 reminder = c;
608 for (c++; c < strlen(format_buffer); c++) {
609 if (isdigit(format_buffer[c])) {
610 continue;
611 }
612 if (format_buffer[c] == 't' ||
613 format_buffer[c] == 'p' ||
614 format_buffer[c] == 'T') {
615 c++;
616 } else {
617 c = reminder;
618 }
619 break;
620 }
621 }
622 syslog_format[w] = format_buffer[c];
623 w++;
624 }
625 qb_log_format_set(QB_LOG_SYSLOG, syslog_format);
626
627 return 0;
628}

Callers 4

main_logging_notifyFunction · 0.85
_logsys_system_setupFunction · 0.85
read_corosync_confFunction · 0.85

Calls 1

logsys_file_format_getFunction · 0.85

Tested by

no test coverage detected