NAME LWP::ConsoleLogger - LWP tracing and debugging VERSION version 0.000033 SYNOPSIS my $ua = LWP::UserAgent->new( cookie_jar => {} ); my $console_logger = LWP::ConsoleLogger->new( dump_content => 1, dump_text => 1, content_pre_filter => sub { my $content = shift; my $content_type = shift; # mangle content here # ... return $content; }, ); $ua->default_header( 'Accept-Encoding' => scalar HTTP::Message::decodable() ); $ua->add_handler( 'response_done', sub { $console_logger->response_callback( @_ ) } ); $ua->add_handler( 'request_send', sub { $console_logger->request_callback( @_ ) } ); # now watch debugging output to your screen $ua->get( 'http://nytimes.com/' ); Or start the easy way. use LWP::ConsoleLogger::Easy qw( debug_ua ); use WWW::Mechanize; my $mech = WWW::Mechanize->new; # or LWP::UserAgent->new() etc my $console_logger = debug_ua( $mech ); $mech->get( 'https://metacpan.org' ); # now watch the console for debugging output # turn off header dumps $console_logger->dump_headers( 0 ); $mech->get( $some_other_url ); Sample output might look like this. GET http://www.nytimes.com/2014/04/24/technology/fcc-new-net-neutrality-rules.html GET params: .-----+-------. | Key | Value | +-----+-------+ | _r | 1 | | hp | | '-----+-------' .-----------------+--------------------------------. | Request Header | Value | +-----------------+--------------------------------+ | Accept-Encoding | gzip | | Cookie2 | $Version="1" | | Referer | http://www.nytimes.com?foo=bar | | User-Agent | WWW-Mechanize/1.73 | '-----------------+--------------------------------' ==> 200 OK Title: The New York Times - Breaking News, World News & Multimedia .--------------------------+-------------------------------. | Response Header | Value | +--------------------------+-------------------------------+ | Accept-Ranges | bytes | | Age | 176 | | Cache-Control | no-cache | | Channels | NytNow | | Client-Date | Fri, 30 May 2014 22:37:42 GMT | | Client-Peer | 170.149.172.130:80 | | Client-Response-Num | 1 | | Client-Transfer-Encoding | chunked | | Connection | keep-alive | | Content-Encoding | gzip | | Content-Type | text/html; charset=utf-8 | | Date | Fri, 30 May 2014 22:37:41 GMT | | NtCoent-Length | 65951 | | Server | Apache | | Via | 1.1 varnish | | X-Cache | HIT | | X-Varnish | 1142859770 1142854917 | '--------------------------+-------------------------------' .--------------------------+-------------------------------. | Text | +--------------------------+-------------------------------+ | F.C.C., in a Shift, Backs Fast Lanes for Web Traffic... | '--------------------------+-------------------------------' DESCRIPTION BETA BETA BETA. This is currently an experiment. Things could change. Please adjust accordingly. It can be hard (or at least tedious) to debug mechanize scripts. LWP::Debug is deprecated. It suggests you write your own debugging handlers, set up a proxy or install Wireshark. Those are all workable solutions, but this module exists to save you some of that work. The guts of this module are stolen from Plack::Middleware::DebugLogging, which in turn stole most of its internals from Catalyst. If you're new to LWP::ConsoleLogger, I suggest getting started with the LWP::ConsoleLogger::Easy wrapper. This will get you up and running in minutes. If you need to tweak the settings that LWP::ConsoleLogger::Easy chooses for you (or if you just want to be fancy), please read on. Since this is a debugging library, I've left as much mutable state as possible, so that you can easily toggle output on and off and otherwise adjust how you deal with the output. CONSTRUCTOR new() The following arguments can be passed to new(), although none are required. They can also be called as methods on an instantiated object. I'll list them here and discuss them in detail below. * "dump_content => 0|1" * "dump_cookies => 0|1" * "dump_headers => 0|1" * "dump_params => 0|1" * "dump_status => 0|1" * "dump_text => 0|1" * "dump_title => 0|1" * "dump_text => 0|1" * "dump_uri => 0|1" * "content_pre_filter => sub { ... }" * "headers_to_redact => ['Authentication', 'Foo']" * "params_to_redact => ['token', 'password']" * "text_pre_filter => sub { ... }" * "html_restrict => HTML::Restrict->new( ... )" * "logger => Log::Dispatch->new( ... )" * "pretty => 0|1" * "term_width => $integer" SUBROUTINES/METHODS dump_content( 0|1 ) Boolean value. If true, the actual content of your response (HTML, JSON, etc) will be dumped to your screen. Defaults to false. dump_cookies( 0|1 ) Boolean value. If true, the content of your cookies will be dumped to your screen. Defaults to false. dump_headers( 0|1 ) Boolean value. If true, both request and response headers will be dumped to your screen. Defaults to true. Headers are dumped in alphabetical order. dump_params( 0|1 ) Boolean value. If true, both GET and POST params will be dumped to your screen. Defaults to true. Params are dumped in alphabetical order. dump_status( 0|1 ) Boolean value. If true, dumps the HTTP response code for each page being visited. Defaults to true. dump_text( 0|1 ) Boolean value. If true, dumps the text of your page after both the content_pre_filter and text_pre_filters have been applied. Defaults to true. dump_title( 0|1 ) Boolean value. If true, dumps the titles of HTML pages if your UserAgent has a c