package WriteLog;
use strict;
use vars qw (@ISA @EXPORT_OK);
use Exporter;
@ISA = ('Exporter');
@EXPORT_OK = qw( WriteLog WriteLogTotals WriteBadFile );

# Author : Gail Binkley
# Date   : 2000-09-13 

# This package includes generic routines for writing log files
# It replaces LoadData.pm, CheckData.pm and DeleteData.pm

####################################################################
sub WriteLog {
####################################################################
# Appends text to a given file handle passed by reference. The text
#   should be a consise summary appropriate for a log file.  
# Usage:   WriteLog(\*LOG, $line);

    my ($fh, $line) = @_;

    print $fh "\n$line\n";

}

####################################################################
sub WriteLogTotals {
####################################################################
# Appends the date, a text string, and count to a given file handle 
#   passed by reference. 
# Usage:   WriteLogTotals(\*LOG, $line, $count);
# Example: Number of records loaded: 23 

    my ($fh, $line, $count) = @_;
    my ($date);

    $date = localtime(time);
    
    print $fh "\n$date\n";
    print $fh "$line: $count\n";
    
}

#####################################################################
sub WriteBadFile {
#####################################################################
# Writes text to a given file handle passed by reference.  The text 
#   is a row that was rejected while loading data into the database.  
#   Thus the file handle contains "bad" data.
# Usage:   WriteBadFile(\*BAD, $row);

    my ($fh, $row) = @_;

    print $fh "$row\n";
    
}
