#!/usr/bin/perl -w
##########################################################################
# $Id: applydate,v 1.1 1998/03/19 04:27:58 kirk Exp $
##########################################################################
# $Log: applydate,v $
# Revision 1.1  1998/03/19 04:27:58  kirk
# Added support form /var/log/cron messages
#
##########################################################################

########################################################
# This was written and is maintained by:
#    Kirk Bauer <kirk@kaybee.org>
#
# Please send all comments, suggestions, bug reports,
#    etc, to kirk@kaybee.org.
#
########################################################

# I plan to add a *lot* more date flexibility at a later time...

if ( $ENV{'LOGWATCH_DATE_RANGE'} eq "yesterday") {
   $SearchDate = `/bin/date -d "1 day ago" +"%m/%d"`;
}
elsif ( $ENV{'LOGWATCH_DATE_RANGE'} eq "today") {
   $SearchDate = `/bin/date +"%m/%d"`;
}
elsif ( $ENV{'LOGWATCH_DATE_RANGE'} eq "all") {
   $SearchDate = "../..";
}

# get rid of any carriage return
chomp($SearchDate);

if ( $ENV{'LOGWATCH_DEBUG'} > 5 ) {
   print STDERR "DEBUG: Inside ApplyDate (cron)...\n";
   print STDERR "DEBUG: Range: " . $ENV{'LOGWATCH_DATE_RANGE'} . "\n";
   print STDERR "DEBUG: Looking For: " . $SearchDate . "\n";
}

while (defined($ThisLine = <STDIN>)) {
    if ($ThisLine =~ m/^[^ ]+ \($SearchDate-..:..:..-[0123456789]+\) /o) {
      print $ThisLine;
    }
}
