don't dump to STDERR if log is available
authorDobrica Pavlinusic <dpavlin@rsync1.maxxo.com>
Sun, 12 Feb 2012 19:33:47 +0000 (20:33 +0100)
committerDobrica Pavlinusic <dpavlin@rsync1.maxxo.com>
Sun, 12 Feb 2012 19:33:47 +0000 (20:33 +0100)
lib/WarnColor.pm

index 14314d8..1a40fee 100644 (file)
@@ -32,10 +32,12 @@ sub BEGIN {
                print STDERR "creating $log\n" unless -e $log;
 
                open(my $fh, '>>', $log);
-               print $fh $line;
-               close $fh;
-
-               print STDERR $line; # XXX debug
+               if ( $fh ) {
+                       print $fh $line;
+                       close $fh;
+               } else {
+                       print STDERR $line;
+               }
        }
 
 if ( -t STDOUT ) { # colorize only if run from terminal !