NAME

LWP::UserAgent::patch::log_response - Patch module for LWP::UserAgent

VERSION

version 0.02

SYNOPSIS

use LWP::UserAgent::patch::log_response
    -log_response_header => 1, # default 1
    -log_response_body   => 1, # default 0
;

# now all your LWP HTTP responses are logged

Sample script and output:

% TRACE=1 perl -MLog::Any::App -MLWP::UserAgent::patch::log_response \
  -MLWP::Simple -e'getprint "http://www.google.com/"'

DESCRIPTION

This module patches LWP::UserAgent (which is used by LWP::Simple, WWW::Mechanize, among others) so that HTTP responses are logged using Log::Any.

Response body is logged in category LWP_Response_Body.* so it can be separated. For example, to dump response body dumps to directory instead of file:

use Log::Any::App '$log',
   -category_level => {LWP_Response_Body => 'off'},
   -dir            => {
       path           => "/path/to/dir",
       level          => 'off',
       category_level => {LWP_Response_Body => 'trace'},
   };

FAQ

Why not subclass?

By patching, you do not need to replace all the client code which uses LWP (or WWW::Mechanize, etc).

SEE ALSO

Use Net::HTTP::Methods::patch::log_request to log raw HTTP requests being sent to servers.

AUTHOR

Steven Haryanto <stevenharyanto@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Steven Haryanto.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.