diff options
author | Karl Berry <karl@freefriends.org> | 2017-04-18 23:10:57 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-04-18 23:10:57 +0000 |
commit | 40b4b6e177c62a14c166dbba6adf3abc415af4b2 (patch) | |
tree | 2996bf29509c806bd8064fb6cf38092c1b375ff8 /Master/tlpkg/tlperl/site/lib/LWP/Debug.pm | |
parent | 8e743c86b6872f30b7a35c72aa944455157d4b3f (diff) |
tlperl 5.24.1 from siep
git-svn-id: svn://tug.org/texlive/trunk@43914 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlperl/site/lib/LWP/Debug.pm')
-rw-r--r-- | Master/tlpkg/tlperl/site/lib/LWP/Debug.pm | 83 |
1 files changed, 40 insertions, 43 deletions
diff --git a/Master/tlpkg/tlperl/site/lib/LWP/Debug.pm b/Master/tlpkg/tlperl/site/lib/LWP/Debug.pm index 99011d57ab7..f7334c425df 100644 --- a/Master/tlpkg/tlperl/site/lib/LWP/Debug.pm +++ b/Master/tlpkg/tlperl/site/lib/LWP/Debug.pm @@ -1,65 +1,58 @@ -package LWP::Debug; # legacy - +package LWP::Debug; # legacy +$LWP::Debug::VERSION = '6.25'; require Exporter; -@ISA = qw(Exporter); -@EXPORT_OK = qw(level trace debug conns); +our @ISA = qw(Exporter); +our @EXPORT_OK = qw(level trace debug conns); use Carp (); my @levels = qw(trace debug conns); -%current_level = (); - +our %current_level = (); -sub import -{ - my $pack = shift; +sub import { + my $pack = shift; my $callpkg = caller(0); my @symbols = (); - my @levels = (); + my @levels = (); for (@_) { - if (/^[-+]/) { - push(@levels, $_); - } - else { - push(@symbols, $_); - } + if (/^[-+]/) { + push(@levels, $_); + } + else { + push(@symbols, $_); + } } Exporter::export($pack, $callpkg, @symbols); level(@levels); } - -sub level -{ +sub level { for (@_) { - if ($_ eq '+') { # all on - # switch on all levels - %current_level = map { $_ => 1 } @levels; - } - elsif ($_ eq '-') { # all off - %current_level = (); - } - elsif (/^([-+])(\w+)$/) { - $current_level{$2} = $1 eq '+'; - } - else { - Carp::croak("Illegal level format $_"); - } + if ($_ eq '+') { # all on + # switch on all levels + %current_level = map { $_ => 1 } @levels; + } + elsif ($_ eq '-') { # all off + %current_level = (); + } + elsif (/^([-+])(\w+)$/) { + $current_level{$2} = $1 eq '+'; + } + else { + Carp::croak("Illegal level format $_"); + } } } +sub trace { _log(@_) if $current_level{'trace'}; } +sub debug { _log(@_) if $current_level{'debug'}; } +sub conns { _log(@_) if $current_level{'conns'}; } -sub trace { _log(@_) if $current_level{'trace'}; } -sub debug { _log(@_) if $current_level{'debug'}; } -sub conns { _log(@_) if $current_level{'conns'}; } - - -sub _log -{ +sub _log { my $msg = shift; - $msg .= "\n" unless $msg =~ /\n$/; # ensure trailing "\n" + $msg .= "\n" unless $msg =~ /\n$/; # ensure trailing "\n" - my($package,$filename,$line,$sub) = caller(2); + my ($package, $filename, $line, $sub) = caller(2); print STDERR "$sub: $msg"; } @@ -67,6 +60,8 @@ sub _log __END__ +=pod + =head1 NAME LWP::Debug - deprecated @@ -85,8 +80,8 @@ section provides some hints about recommended replacements. =head2 Network traffic monitoring The best way to monitor the network traffic that LWP generates is to -use an external TCP monitoring program. The Wireshark program -(L<http://www.wireshark.org/>) is highly recommended for this. +use an external TCP monitoring program. The +L<WireShark|http://www.wireshark.org/> program is highly recommended for this. Another approach it to use a debugging HTTP proxy server and make LWP direct all its traffic via this one. Call C<< $ua->proxy >> to @@ -108,3 +103,5 @@ request and response objects that pass through LWP: =head1 SEE ALSO L<LWP::UserAgent> + +=cut |