X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=onis;h=b0d1bdc70a44cf31c272ead65611ba7f24a12274;hb=6117e7a610673e050a92ae8fb2f91386dd0673f3;hp=7d794b0fcc181f0e1009cc2862a14e0074d072e0;hpb=b4e0c0ebf1aa8c2f59ee43461817e7c771c62420;p=onis.git diff --git a/onis b/onis index 7d794b0..b0d1bdc 100755 --- a/onis +++ b/onis @@ -48,7 +48,7 @@ if (!$VERSION) $VERSION =~ s/^\D*(\d+).*/r$1/; } -our $FILEINFO; +our $FileInfo; our $PURGE_LOGS = 0; print STDERR $/, __FILE__, ': $Id$' if ($::DEBUG); @@ -71,6 +71,7 @@ foreach ('Core', get_config ('plugin')) if (!get_config ('input')) { + # TODO: Make a complete (!) lsit.. print STDERR < [logfile logfile ..] @@ -126,11 +127,11 @@ if (get_config ('logtype')) require "Onis/Parser/$logtype.pm"; require Onis::Parser::Persistent; require Onis::Data::Persistent; -import Onis::Parser qw/parse last_date/; -import Onis::Parser::Persistent qw#newfile#; -import Onis::Data::Persistent qw#init#; +import Onis::Parser (qw(parse last_date)); +import Onis::Parser::Persistent (qw(newfile)); +import Onis::Data::Persistent (); -$FILEINFO = init ('$FILEINFO', 'hash'); +$FileInfo = Onis::Data::Persistent->new ('FileInfo', 'inode', qw(mtime)); if (get_config ('purge_logs')) { @@ -167,15 +168,18 @@ for (get_config ('input')) } else { + my ($old_mtime) = $FileInfo->get ($inode); + print STDERR $/, __FILE__, ": ``$file'': " if ($::DEBUG & 0x200); - if (defined ($FILEINFO->{$inode}{'mtime'})) + + if (defined ($old_mtime)) { - if ($FILEINFO->{$inode}{'mtime'} == $mtime) + if ($old_mtime == $mtime) { print STDERR "File did not change. Skipping." if ($::DEBUG & 0x200); next; } - elsif ($FILEINFO->{$inode}{'mtime'} < $mtime) + elsif ($old_mtime < $mtime) { print STDERR "File changed. Reading it again." if ($::DEBUG & 0x200); } @@ -188,7 +192,7 @@ for (get_config ('input')) { print STDERR "File appears to be new. Reading it." if ($::DEBUG & 0x200); } - $FILEINFO->{$inode}{'mtime'} = $mtime; + $FileInfo->put ($inode, $mtime); } # truncate @@ -228,7 +232,7 @@ for (get_config ('input')) } } - newfile ($FILEINFO->{$inode}); + newfile ($FileInfo->{$inode}); while (<$logfile>) { s/\n|\r//g; @@ -279,7 +283,7 @@ for (get_config ('input')) { print STDERR $/, __FILE__, ": Unable to delete empty file ``$file'': $!"; } - delete ($FILEINFO->{$inode}); + delete ($FileInfo->{$inode}); } else {