Skip to content
Snippets Groups Projects
Commit a91ce56c authored by Graham McVicker's avatar Graham McVicker
Browse files

Logs statmsgs to file

parent eb3a02da
No related branches found
No related tags found
No related merge requests found
use strict;
use warnings;
use FileHandle;
use IO::File;
use Bio::EnsEMBL::Utils::Exception qw(throw);
#
# This is a class for logging StatMsgs to a file
# all it does is write stat codes to a file and
# ensure that duplicates are not written twice.
#
package StatLogger;
sub new {
my $class = shift;
my $filename = shift;
my $fh;
if($filename) {
$fh = IO::File->new();
$fh->open(">$filename") or throw("Could not open file $filename.");
$fh->autoflush();
} else {
$fh = \*STDOUT;
}
return bless {'fh' => $fh,
'seen_msgs' => {}}, $class;
}
sub add_StatMsg {
my $self = shift;
my $msg = shift;
my $fh = $self->{'fh'};
if(!$self->{'seen_msgs'}->{$msg->id}) {
print $fh $msg->code(), "\n";
$self->{'seen_msgs'}->{$msg->id()} = 1;
}
}
1;
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment