summaryrefslogtreecommitdiffstats
path: root/src/windows/build/Logger.pm
diff options
context:
space:
mode:
authorKevin Koch <kpkoch@mit.edu>2007-03-16 18:38:28 +0000
committerKevin Koch <kpkoch@mit.edu>2007-03-16 18:38:28 +0000
commit896e355909c46a743321afe6b95afbe7a8c8e18f (patch)
tree98a09c8ff271d91a881bd1f3e4ad4ba94caca5fb /src/windows/build/Logger.pm
parentdeb3ee503652cc84959dda74e2c0a164a7a584cd (diff)
downloadkrb5-896e355909c46a743321afe6b95afbe7a8c8e18f.tar.gz
krb5-896e355909c46a743321afe6b95afbe7a8c8e18f.tar.xz
krb5-896e355909c46a743321afe6b95afbe7a8c8e18f.zip
KfW automated build scripts & supporting files
Updated scripts & additional configuration files. Ticket: new Target_Version: 1.6.1 tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19234 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/windows/build/Logger.pm')
-rw-r--r--src/windows/build/Logger.pm87
1 files changed, 87 insertions, 0 deletions
diff --git a/src/windows/build/Logger.pm b/src/windows/build/Logger.pm
new file mode 100644
index 0000000000..f74c218076
--- /dev/null
+++ b/src/windows/build/Logger.pm
@@ -0,0 +1,87 @@
+package Logger;
+
+use strict;
+use IO::File;
+use FindBin;
+
+my $bStarted = 0;
+
+sub new {
+ my $class = shift;
+ my $file = shift;
+ my $append = shift;
+ $file || die "Usage: \$foo = new Logger filename [append]\n";
+ my $self = {};
+ bless $self, $class;
+ $self->{FILE} = $file;
+ $self->{APPEND} = $append?'-a':'';
+ return $self;
+}
+
+sub start {
+ my $self = shift;
+
+ return 1 if $self->{PIPE};
+
+ STDOUT->flush;
+ STDERR->flush;
+
+ my $fh_out = new IO::File;
+ my $fh_err = new IO::File;
+ my $fh_pipe = new IO::File;
+
+ $self->{OUT} = $fh_out;
+ $self->{ERR} = $fh_err;
+ $self->{PIPE} = $fh_pipe;
+
+ $fh_out->open(">&STDOUT") || die;
+ $fh_err->open(">&STDERR") || die;
+ $fh_pipe->open("|$^X $FindBin::Bin/tee.pl $self->{APPEND} $self->{FILE}") || die;
+
+ STDOUT->fdopen(fileno $fh_pipe, "w") || die;
+ STDERR->fdopen(fileno $fh_pipe, "w") || die;
+
+ STDOUT->autoflush(1);
+ STDERR->autoflush(1);
+
+ $SIG{__DIE__} = sub {
+ print STDERR $_[0];
+ $self->stop;
+ die "\n";
+ };
+
+ $bStarted = 1;
+ return 1;
+}
+
+# 20070314 kpkoch:
+# There appears to be a bug in ActivePerl where Logger's games with streams
+# and the SIG DIE handler cause eval to throw exceptions. By deleting the DIE handler,
+# subsequent evals do not fail.
+sub no_die_handler {
+ delete $SIG{__DIE__};
+ }
+
+sub stop {
+ my $self = shift;
+
+ return 0 if !$self->{PIPE};
+
+ STDOUT->close;
+ STDERR->close;
+ $self->{PIPE}->close;
+ STDOUT->fdopen(fileno $self->{OUT}, "w");
+ STDERR->fdopen(fileno $self->{ERR}, "w");
+ delete $self->{OUT};
+ delete $self->{ERR};
+ delete $self->{PIPE};
+ $bStarted = 0;
+ return 1;
+}
+
+sub DESTROY {
+ my $self = shift;
+ $self->stop if ($bStarted);
+ }
+
+1;