LWP::Debug - debug routines
use LWP::Debug; level('+'); level('-conns'); trace('send()'); debug('url ok'); conns("read $n bytes: $data"); debugl("Resolving hostname '$host'"); $SIG{'ALRM'} = 't'; alarm(1); sub t { my $long = $LWP::Debug::longMsg(); my $msg = 'Timeout'; $msg .= ": $long" if defined $long; die $msg; }
LWP::Debug provides tracing facilities. The trace, debug and conns function log information at increasing levels of detail. Which level of detail is actually printed is controlled with the level() function.
trace
debug
conns
level()
See LWP for a complete overview of libwww-perl5.
The trace() function is used for tracing function calls. The package and calling subroutine name is printed along with the passed argument. This should be called at the start of every major function.
trace()
The debug() function is used for high-granularity reporting of state in functions.
debug()
The conns() function is used to show data being transferred over the connections. This may generate considerable output.
conns()
The debugl function is meant for operations which take long time; The message is processed by debug(), and stored for later use by for example an SIGALRM signal handler.
debugl
The level() function controls the level of detail being logged. Passing '+' or '-' indicates full and no logging respectively. Inidividual levels can switched on and of by passing the name of the level with a '+' or '-' prepended.
Retrieve message set by debugl()
To install LWP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm LWP
CPAN shell
perl -MCPAN -e shell install LWP
For more information on module installation, please visit the detailed CPAN module installation guide.