Re: emerge log time range

Jason <[email protected]>
Newsgroups gmane.comp.log.logwatch.devel
Message-ID <[email protected]>
Now, I've never done anything with perl before, so this is almost
certainly ugly, and it also seems pretty crappy performance wise, but
what about these changes to emerge/applydate?  I just use strftime to
convert the seconds since epoch to a regular time format since
TimeFilter doesn't handle the '%s' correctly.  I could be looking at
the completely the wrong way though, so if there's a better way I'd be
willing to look into it.

29a30,31
> use POSIX qw(strftime);
>
33c35
< my $SearchDate = TimeFilter('%b %d, %Y');
---
> my $SearchDate = TimeFilter('%b %e %H:%M:%S');
42a45
> my $emergeTime = 0;
44c47,57
<         if ($line =~ /Started emerge on: $SearchDate/) {
---
>       $line =~ /(\d+):.*/;
>       $emergeTime = strftime('%b %e %H:%M:%S', localtime($1));
>
>       if ($Debug > 5) {
>               print STDERR "DEBUG: converted time: $emergeTime\n";
>       }
>
>       if ($emergeTime =~ /$SearchDate/) {
47,50c60,72
<         elsif ($line =~ /Started emerge on:/) {
<                 $printLine = 0;
<         }
<         print $line if ($printLine == 1);
---
>
>
>       print $line if ($printLine == 1);
>
>         $printLine = 0;
>


On 2/5/07, Jason <[email protected]> wrote:
> Sure, though unfortunately it's not the standard format.  Every line
> starts with the date in seconds since epoch.  I'm not sure there's a
> good way to limit it to only the specified time range, but anything
> that close to and not less than would certainly be better.  Here is an
> example of one emerge from the logs.
>
> 1170280647: Started emerge on: Jan 31, 2007 16:57:27
> 1170280647:  *** emerge --ask --update --verbose pam
> 1170280651:  >>> emerge (1 of 1) sys-libs/pam-0.78-r5 to /
> 1170280651:  === (1 of 1) Cleaning
> (sys-libs/pam-0.78-r5::/usr/portage/sys-libs/pam/pam-0.78-r5.ebuild)
> 1170280652:  === (1 of 1) Compiling/Merging
> (sys-libs/pam-0.78-r5::/usr/portage/sys-libs/pam/pam-0.78-r5.ebuild)
> 1170280661:  *** terminating.
>
>
> On 2/4/07, Bjorn L. <[email protected]> wrote:
> >
> >
> > MrC wrote:
> >
> > > The emerge script appears to search for the day selected via --range
> > > (default yesterday), regardless of hour, etc.
> > >
> > > You can see this in the script:
> > >
> > >  /usr/share/logwatch/scripts/logfiles/emerge/applydate
> > >
> > > as the TimeFilter is looking for dates matching "%b %d, %Y", which is Mon
> > > Day, Year.
> >
> > Jason,
> >
> > Do you have an example of what a log entry looks like?  If it has the
> > hours:minutes:seconds, and it's in a readily obtainable format, it
> > should be easy to change.
> > _______________________________________________
> > Logwatch-Devel mailing list
> > [email protected]
> > http://www2.list.logwatch.org:81/mailman/listinfo/logwatch-devel
> >
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.