Turn a for loop that's almost a while into an honest-to-goodness while.
[p5sagit/p5-mst-13.2.git] / lib / CPAN / Debug.pm
CommitLineData
e82b9348 1package CPAN::Debug;
2use strict;
3use vars qw($VERSION);
4
5$VERSION = sprintf "%.2f", substr(q$Rev: 286 $,4)/100;
6# module is internal to CPAN.pm
7
8%CPAN::DEBUG = qw[
9 CPAN 1
10 Index 2
11 InfoObj 4
12 Author 8
13 Distribution 16
14 Bundle 32
15 Module 64
16 CacheMgr 128
17 Complete 256
18 FTP 512
19 Shell 1024
20 Eval 2048
21 HandleConfig 4096
22 Tarzip 8192
23 Version 16384
24 Queue 32768
25];
26
27$CPAN::DEBUG ||= 0;
28
29#-> sub CPAN::Debug::debug ;
30sub debug {
31 my($self,$arg) = @_;
32 my($caller,$func,$line,@rest) = caller(1); # caller(0) eg
33 # Complete, caller(1)
34 # eg readline
35 ($caller) = caller(0);
36 $caller =~ s/.*:://;
37 $arg = "" unless defined $arg;
38 my $rest = join "|", map { defined $_ ? $_ : "UNDEF" } @rest;
39 if ($CPAN::DEBUG{$caller} & $CPAN::DEBUG){
40 if ($arg and ref $arg) {
41 eval { require Data::Dumper };
42 if ($@) {
43 $CPAN::Frontend->myprint($arg->as_string);
44 } else {
45 $CPAN::Frontend->myprint(Data::Dumper::Dumper($arg));
46 }
47 } else {
48 $CPAN::Frontend->myprint("Debug($caller:$func,$line,[$rest]): $arg\n");
49 }
50 }
51}
52
531;