When current log is empty, show most recent rotated log
authorJamie Cameron <jcameron@webmin.com>
Mon, 18 Feb 2008 02:37:42 +0000 (02:37 +0000)
committerJamie Cameron <jcameron@webmin.com>
Mon, 18 Feb 2008 02:37:42 +0000 (02:37 +0000)
syslog/save_log.cgi
syslog/syslog-lib.pl

index 730069e..bf1d097 100755 (executable)
@@ -100,10 +100,10 @@ elsif ($in{'view'}) {
                        $catter = $cmd;
                        }
                else {
-                       # Find the first non-empty file
+                       # Find the first non-empty file, newest first
                        $catter = "cat ".quotemeta($file);
                        if (!-s $file && $config{'compressed'}) {
-                               foreach $l (&all_log_files($file)) {
+                               foreach $l (reverse(&all_log_files($file))) {
                                        next if (!-s $l);
                                        $c = &catter_command($l);
                                        if ($c) {
index 2cffcb2..9e5eea9 100644 (file)
@@ -257,7 +257,7 @@ local ($f, @rv);
 opendir(DIR, &translate_filename($dir));
 foreach $f (readdir(DIR)) {
        local $trans = &translate_filename("$dir/$f");
-       if ($f =~ /^\Q$base\E/ && -f $trans) {
+       if ($f =~ /^\Q$base\E/ && -f $trans && $f !~ /\.offset$/) {
                push(@rv, "$dir/$f");
                $mtime{"$dir/$f"} = [ stat($trans) ];
                }