Revision 41df62c1
Added by Jim Pingle over 9 years ago
src/usr/local/www/guiconfig.inc | ||
---|---|---|
555 | 555 |
$changecount++; |
556 | 556 |
} |
557 | 557 |
|
558 |
function clear_log_file($logfile = "/var/log/system.log", $restart_syslogd = true) { |
|
559 |
global $config, $g; |
|
560 |
if ($restart_syslogd) { |
|
561 |
exec("/usr/bin/killall syslogd"); |
|
562 |
} |
|
563 |
if (isset($config['system']['disablesyslogclog'])) { |
|
564 |
unlink($logfile); |
|
565 |
touch($logfile); |
|
566 |
} else { |
|
567 |
$log_size = isset($config['syslog']['logfilesize']) ? $config['syslog']['logfilesize'] : "511488"; |
|
568 |
$log_size = isset($config['syslog'][basename($logfile, '.log') . '_settings']['logfilesize']) ? $config['syslog'][basename($logfile, '.log') . '_settings']['logfilesize'] : $log_size; |
|
569 |
if (isset($config['system']['usefifolog'])) { |
|
570 |
exec("/usr/sbin/fifolog_create -s {$log_size} " . escapeshellarg($logfile)); |
|
571 |
} else { |
|
572 |
exec("/usr/local/sbin/clog -i -s {$log_size} " . escapeshellarg($logfile)); |
|
573 |
} |
|
574 |
} |
|
575 |
if ($restart_syslogd) { |
|
576 |
system_syslogd_start(); |
|
577 |
} |
|
578 |
} |
|
579 |
|
|
580 |
function clear_all_log_files() { |
|
581 |
global $g; |
|
582 |
exec("/usr/bin/killall syslogd"); |
|
583 |
|
|
584 |
$log_files = array("system", "filter", "dhcpd", "vpn", "pptps", "poes", "l2tps", "openvpn", "portalauth", "ipsec", "ppp", "relayd", "wireless", "lighttpd", "ntpd", "gateways", "resolver", "routing"); |
|
585 |
foreach ($log_files as $lfile) { |
|
586 |
clear_log_file("{$g['varlog_path']}/{$lfile}.log", false); |
|
587 |
} |
|
588 |
|
|
589 |
system_syslogd_start(); |
|
590 |
killbyname("dhcpd"); |
|
591 |
services_dhcpd_configure(); |
|
592 |
return; |
|
593 |
} |
|
594 |
|
|
595 | 558 |
// This version of dump_clog() does not output <td></td> or any other table elements. |
596 | 559 |
function dump_clog_no_table($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert = "") { |
597 | 560 |
global $g, $config; |
... | ... | |
615 | 578 |
if ($config['system']['disablesyslogclog']) { |
616 | 579 |
exec("cat " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr); |
617 | 580 |
} else { |
618 |
if (isset($config['system']['usefifolog'])) { |
|
619 |
exec("/usr/sbin/fifolog_reader " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr); |
|
620 |
} else { |
|
621 |
exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . "{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr); |
|
622 |
} |
|
581 |
exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . "{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr); |
|
623 | 582 |
} |
624 | 583 |
} |
625 | 584 |
echo "\n"; |
... | ... | |
630 | 589 |
$logent = preg_split("/\s+/", $logent, 6); |
631 | 590 |
|
632 | 591 |
if ($withorig) { |
633 |
if (isset($config['system']['usefifolog'])) { |
|
634 |
$entry_date_time = htmlspecialchars(date("F j, Y, g:i a", "" . $logent[1] . "")); |
|
635 |
$entry_text = htmlspecialchars($logent[5]); |
|
636 |
} else { |
|
637 |
$entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3))); |
|
638 |
$entry_text = ($logent[3] == $config['system']['hostname']) ? "" : $logent[3] . " "; |
|
639 |
$entry_text .= htmlspecialchars($logent[4] . " " . $logent[5]); |
|
640 |
} |
|
592 |
$entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3))); |
|
593 |
$entry_text = ($logent[3] == $config['system']['hostname']) ? "" : $logent[3] . " "; |
|
594 |
$entry_text .= htmlspecialchars($logent[4] . " " . $logent[5]); |
|
641 | 595 |
echo "{$entry_date_time}"; |
642 | 596 |
echo " " . "{$entry_text}" . "\n"; |
643 | 597 |
} else { |
... | ... | |
670 | 624 |
if ($config['system']['disablesyslogclog']) { |
671 | 625 |
exec("cat " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr); |
672 | 626 |
} else { |
673 |
if (isset($config['system']['usefifolog'])) { |
|
674 |
exec("/usr/sbin/fifolog_reader " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr); |
|
675 |
} else { |
|
676 |
exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . "{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr); |
|
677 |
} |
|
627 |
exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . "{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr); |
|
678 | 628 |
} |
679 | 629 |
} |
680 | 630 |
|
... | ... | |
684 | 634 |
$logent = preg_split("/\s+/", $logent, 6); |
685 | 635 |
echo "<tr>\n"; |
686 | 636 |
if ($withorig) { |
687 |
if (isset($config['system']['usefifolog'])) { |
|
688 |
$entry_date_time = htmlspecialchars(date("F j, Y, g:i a", "" . $logent[1] . "")); |
|
689 |
$entry_text = htmlspecialchars($logent[5]); |
|
690 |
} else { |
|
691 |
$entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3))); |
|
692 |
$entry_text = ($logent[3] == $config['system']['hostname']) ? "" : $logent[3] . " "; |
|
693 |
$entry_text .= htmlspecialchars($logent[4] . " " . $logent[5]); |
|
694 |
} |
|
637 |
$entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3))); |
|
638 |
$entry_text = ($logent[3] == $config['system']['hostname']) ? "" : $logent[3] . " "; |
|
639 |
$entry_text .= htmlspecialchars($logent[4] . " " . $logent[5]); |
|
695 | 640 |
echo "<td style=\"white-space:nowrap;\">{$entry_date_time}</td>\n"; |
696 | 641 |
echo "<td style=\"word-wrap:break-word; word-break:break-all; white-space:normal\">{$entry_text}</td>\n"; |
697 | 642 |
} else { |
... | ... | |
719 | 664 |
if ($config['system']['disablesyslogclog']) { |
720 | 665 |
exec("cat " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr); |
721 | 666 |
} else { |
722 |
if (isset($config['system']['usefifolog'])) { |
|
723 |
exec("/usr/sbin/fifolog_reader " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr); |
|
724 |
} else { |
|
725 |
exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . "{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr); |
|
726 |
} |
|
667 |
exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . "{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr); |
|
727 | 668 |
} |
728 | 669 |
return($logarr); |
729 | 670 |
} |
Also available in: Unified diff
Nuke fifolog support. It was never used or fully implemented, no GUI option, and didn't end up working out.
It buffered writes too long, users could never see the most current log data.