Explorar o código

Dpkg::ErrorHandling: Support changing the file handle for info()

Sometimes we need not clutter STDOUT when outputting data there.
Guillem Jover %!s(int64=17) %!d(string=hai) anos
pai
achega
d07ecdda8a
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      scripts/Dpkg/ErrorHandling.pm

+ 5 - 1
scripts/Dpkg/ErrorHandling.pm

@@ -9,6 +9,7 @@ our @EXPORT = qw(report_options info warning error errormsg
 our @EXPORT_OK = qw(report unknown);
 
 my $quiet_warnings = 0;
+my $info_fh = \*STDOUT;
 
 sub report_options
 {
@@ -17,6 +18,9 @@ sub report_options
     if (exists $options{quiet_warnings}) {
         $quiet_warnings = $options{quiet_warnings};
     }
+    if (exists $options{info_fh}) {
+        $info_fh = $options{info_fh};
+    }
 }
 
 sub report(@)
@@ -29,7 +33,7 @@ sub report(@)
 
 sub info($;@)
 {
-    print report(_g("info"), @_) if (!$quiet_warnings);
+    print $info_fh report(_g("info"), @_) if (!$quiet_warnings);
 }
 
 sub warning($;@)