| 1 | package Net::HTTP::Methods::Patch::LogRequest; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | our $DATE = '2018-04-26'; # DATE | |||||||||
| 4 | 1 | our $VERSION = '0.11'; # VERSION | |||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use 5.010001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | no warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use Module::Patch; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use base qw(Module::Patch); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 1 | our %config; | |||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | my $p_format_request = sub { | ||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||
| 16 | 0 | require Log::ger; | |||||||||
| 17 | 0 | my $log = Log::ger->get_logger; | |||||||||
| 18 | |||||||||||
| 19 | 0 | my $ctx = shift; | |||||||||
| 20 | 0 | my $orig = $ctx->{orig}; | |||||||||
| 21 | 0 | my $res = $orig->(@_); | |||||||||
| 22 | |||||||||||
| 23 | 0 | ▶ | my $proto = ref($_[0]) =~ /^LWP::Protocol::(\w+)::/ ? $1 : "?"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | |||||||||||
| 25 | 0 | ▶ | if ($log->is_trace) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | |||||||||||
| 27 | # XXX use equivalent for Log::ger | ||||||||||
| 28 | |||||||||||
| 29 | # # there is no equivalent of caller_depth in Log::Any, so we do this only | ||||||||||
| 30 | # # for Log4perl | ||||||||||
| 31 | # local $Log::Log4perl::caller_depth = $Log::Log4perl::caller_depth + 1 | ||||||||||
| 32 | # if $Log::{"Log4perl::"}; | ||||||||||
| 33 | |||||||||||
| 34 | 0 | $log->trace("HTTP request (proto=%s, len(headers)=%d):\n%s", | |||||||||
| 35 | $proto, length($res), $res); | ||||||||||
| 36 | } | ||||||||||
| 37 | 0 | $res; | |||||||||
| 38 | 1 | }; | |||||||||
| 39 | |||||||||||
| 40 | 0 | ▶ | sub patch_data { | ||||||||
|
Subroutine
patch_data: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 41 | return { | ||||||||||
| 42 | 0 | v => 3, | |||||||||
| 43 | patches => [ | ||||||||||
| 44 | { | ||||||||||
| 45 | action => 'wrap', | ||||||||||
| 46 | mod_version => qr/^6\.*/, | ||||||||||
| 47 | sub_name => 'format_request', | ||||||||||
| 48 | code => $p_format_request, | ||||||||||
| 49 | }, | ||||||||||
| 50 | ], | ||||||||||
| 51 | }; | ||||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 1 | 1; | |||||||||
| 55 | # ABSTRACT: Log raw HTTP requests | ||||||||||
| 56 | |||||||||||
| 57 | __END__ | ||||||||||