chiark / gitweb /
Debugging: use typeglobs to simplify various things (nfc)
[dgit.git] / Debian / Dgit.pm
index 2b9479db58d9b4e5f07c0301033657d449475c75..f166f11b58464b7d9616579fb3af89f4ef01a41d 100644 (file)
@@ -18,7 +18,7 @@ BEGIN {
                       stat_exists git_for_each_ref
                       $package_re $component_re $branchprefix
                       initdebug enabledebug printdebug debugcmd
-                      $debugprefix $debug
+                      $debugprefix *debuglevel *DEBUG
                       shellquote printcmd);
     %EXPORT_TAGS = ( policyflags => [qw(NOFFCHECK FRESHREPO)] );
     @EXPORT_OK   = @{ $EXPORT_TAGS{policyflags} };
@@ -78,21 +78,21 @@ sub git_for_each_tag_referring ($$) {
 }
 
 our $debugprefix;
-our $debug = 0;
+our $debuglevel = 0;
 
 sub initdebug ($) { 
     ($debugprefix) = @_;
-    open ::DEBUG, ">/dev/null" or die $!;
+    open DEBUG, ">/dev/null" or die $!;
 }
 
 sub enabledebug () {
-    open ::DEBUG, ">&STDERR" or die $!;
-    ::DEBUG->autoflush(1);
-    $debug ||= 1;
+    open DEBUG, ">&STDERR" or die $!;
+    DEBUG->autoflush(1);
+    $debuglevel ||= 1;
 }
     
 sub printdebug {
-    print ::DEBUG $debugprefix, @_ or die $!;
+    print DEBUG $debugprefix, @_ or die $! if $debuglevel>0;
 }
 
 sub shellquote {
@@ -120,7 +120,7 @@ sub printcmd {
 
 sub debugcmd {
     my $extraprefix = shift @_;
-    printcmd(\*::DEBUG,$debugprefix.$extraprefix,@_) if $debug>0;
+    printcmd(\*DEBUG,$debugprefix.$extraprefix,@_) if $debuglevel>0;
 }
 
 1;