1LWP::ConsoleLogger::EasUys(e3r)Contributed Perl DocumentLaWtPi:o:nConsoleLogger::Easy(3)
2
3
4

NAME

6       LWP::ConsoleLogger::Easy - Easy LWP tracing and debugging
7

VERSION

9       version 0.000042
10

SYNOPSIS

12           use LWP::ConsoleLogger::Easy qw( debug_ua );
13           use WWW::Mechanize;
14
15           my $mech = WWW::Mechanize->new;
16           my $logger = debug_ua( $mech );
17           $mech->get('https://google.com');
18
19           # now watch the console for debugging output
20
21           # ...
22           # stop dumping headers
23           $logger->dump_headers( 0 );
24
25           # Redact sensitive data
26           $ENV{LWPCL_REDACT_HEADERS} = 'Authorization,Foo,Bar';
27           $ENV{LWPCL_REDACT_PARAMS} = 'seekrit,password,credit_card';
28
29           my $quiet_logger = debug_ua( $mech, 1 );
30
31           my $noisy_logger = debug_ua( $mech, 5 );
32

DESCRIPTION

34       This module gives you the easiest possible introduction to
35       LWP::ConsoleLogger.  It offers one wrapper around LWP::ConsoleLogger:
36       "debug_ua".  This function allows you to get up and running quickly
37       with just a couple of lines of code. It instantiates user-agent logging
38       and also returns a LWP::ConsoleLogger object, which you may then tweak
39       to your heart's desire.
40
41       If you're able to install HTML::FormatText::Lynx then you'll get highly
42       readable HTML to text conversions.
43

FUNCTIONS

45   debug_ua( $mech, $verbosity )
46       When called without a verbosity argument, this function turns on all
47       logging.  I'd suggest going with this to start with and then turning
48       down the verbosity after that.   This method returns an
49       LWP::ConsoleLogger object, which you may tweak to your heart's desire.
50
51           my $ua_logger = debug_ua( $ua );
52           $ua_logger->content_pre_filter( sub {...} );
53           $ua_logger->logger( Log::Dispatch->new(...) );
54
55           $ua->get(...);
56
57       $ua may be one of several user-agents, including "LWP::UserAgent",
58       "Mojo::UserAgent", and "WWW::Mechanize".
59
60       You can provide a verbosity level of 0 or more.  (Currently 0 - 8
61       supported.)  This will turn up the verbosity on your output gradually.
62       A verbosity of 0 will display nothing.  8 will display all available
63       outputs.
64
65           # don't get too verbose
66           my $ua_logger = debug_ua( $ua, 4 );
67
68   add_ua_handlers
69       This method sets up response and request handlers on your user agent.
70       This is done for you automatically if you're using "debug_ua".
71

ENVIRONMENT VARIABLES

73   LWPCL_REDACT_HEADERS
74       A comma-separated list of header values to redact from output.
75
76           $ENV{LWPCL_REDACT_HEADERS} = 'Authorization,Foo,Bar';
77
78       Output will be something like:
79
80           .----------------+------------------.
81           | Request Header | Value            |
82           +----------------+------------------+
83           | Authorization  | [REDACTED]       |
84           | Content-Length | 0                |
85           | User-Agent     | libwww-perl/6.15 |
86           '----------------+------------------'
87
88       Use at the command line.
89
90           LWPCL_REDACT_HEADERS='Authorization,Foo,Bar' perl script.pl
91
92   LWPCL_REDACT_PARAMS
93       A comma-separated list of parameter values to redact from output.
94
95           $ENV{LWPCL_REDACT_PARAMS} = 'credit_card,foo,bar';
96
97       Use at the command line.
98
99           LWPCL_REDACT_PARAMS='credit_card,foo,bar' perl script.pl
100
101           .-------------+------------.
102           | Key         | Value      |
103           +-------------+------------+
104           | credit_card | [REDACTED] |
105           '-------------+------------'
106
107   CAVEATS
108       Text formatting now defaults to attempting to use
109       HTML::FormatText::Lynx to format HTML as text.  If you do not have this
110       installed, we'll fall back to using HTML::Restrict to remove any HTML
111       tags which you have not specifically whitelisted.
112
113       If you have HTML::FormatText::Lynx installed, but you don't want to use
114       it, override the default filter:
115
116           my $logger = debug_ua( $mech );
117           $logger->text_pre_filter( sub { return shift } );
118
119   EXAMPLES
120       Please see the "examples" folder in this distribution for more ideas on
121       how to use this module.
122

AUTHOR

124       Olaf Alders <olaf@wundercounter.com>
125
127       This software is Copyright (c) 2014-2019 by MaxMind, Inc.
128
129       This is free software, licensed under:
130
131         The Artistic License 2.0 (GPL Compatible)
132
133
134
135perl v5.30.0                      2019-07-26       LWP::ConsoleLogger::Easy(3)
Impressum