LWP::Co...rywhere(3)
β¨ LWP::ConsoleLogger::Everywhere β¨
bestie. sit down. we're looking at the LWP::ConsoleLogger::Everywhere page β that's the section 3 one, user contributed Perl documentation, the little legend herself π
it's giving "version 1.000003" and it is lowkey iconic because it makes LWP trace everywhere without you lifting a finger. no cap.
πΈ SYNOPSIS πΈ
use LWP::ConsoleLogger::Everywhere;
# somewhere deep down in the guts of your program
# there is some other module that creates an LWP::UserAgent
# and now it will tell you what it's up to
# somewhere else you can access and fine-tune those loggers
# individually:
my $loggers = LWP::ConsoleLogger::Everywhere->loggers;
$loggers->[0]->pretty(0);
# or all of them at once:
LWP::ConsoleLogger::Everywhere->set( pretty => 1);
# Redact sensitive data for all user agents
$ENV{LWPCL_REDACT_HEADERS} = 'Authorization,Foo,Bar';
$ENV{LWPCL_REDACT_PARAMS} = 'seekrit,password,credit_card';
# Or observe without changing your code
PERL5OPT="-MLWP::ConsoleLogger::Everywhere" carton install
perl -MLWP::ConsoleLogger::Everywhere my-script.pl
π¦ DESCRIPTION π¦
okay so here's the tea β β this module turns on LWP::ConsoleLogger::Easy debugging for every single LWP::UserAgent, Mojo::UserAgent, or HTTP::Tiny based user agent anywhere in your code. fr fr. it does not matter what package or class it lives in, and it does not matter if you even have access to the object itself. all you gotta do is use this module somewhere in your code and boom π₯ it works.
once the loggers exist, you can grab them and configure them one by one with the loggers class method. or if you're feeling efficient (main character energy π) you can change all of them at once with the set class method instead.
want a practical lil demo of how to use this? go peek at: <https://www.olafalders.com/2021/12/01/observing-network-traffic-with-lwp-consolelogger-everywhere/>
π CLASS METHODS π
π set( <setting> => <value> )
LWP::ConsoleLogger::Everywhere->set( dump_content => 0 );
this class method changes the given setting on all logger objects that have been created so far. first arg = the accessor name of the setting you wanna change. second arg = the new value. and listen β it cannot be used to read current values, so don't try it π. wanna know what all those settings actually are? check out METHODS in LWP::ConsoleLogger#SUBROUTINES.
π loggers
my $loggers = LWP::ConsoleLogger::Everywhere->loggers;
foreach my $logger ( @{ $loggers } ) {
# stop dumping headers
$logger->dump_headers( 0 );
}
this class method hands you back an array reference of every LWP::ConsoleLogger object created so far, with the newest one chilling at the end. use them to fine-tune settings to your heart's content π
heads up though: if your app has more than one user agent, you're gonna have to figure out which one is which yourself. and since this whole thing is for debugging only, trial and error is a genuinely good strategy here. slay.
π ENVIRONMENT VARIABLES π
π LWPCL_LOGFILE
by default, all the data gets dumped to your console (hence the whole "Console" in the module name, bestie) using Log::Dispatch. but you can change that behavior.
the general approach is doing it from inside your script, like this:
use LWP::ConsoleLogger::Everywhere;
my $loggers = LWP::ConsoleLogger::Everywhere->loggers;
my $log_dispatch = Log::Dispatch->new(
outputs => [
[ 'File', min_level => 'debug', filename => 'log_file.txt' ],
[ 'Screen', min_level => 'debug' ],
],
);
foreach my $logger ( @{ $loggers } ) {
$logger->logger($log_dispatch);
}
the second approach is way simpler and it's done via an environment variable. for example you can run your script like:
LWPCL_LOGFILE=foo.log perl -MLWP::ConsoleLogger::Everywhere foo.pl
and that is equivalent to the first approach with the following Log::Dispatch logger:
my $log_dispatch = Log::Dispatch->new(
outputs => [ [ 'File', min_level => 'debug', filename => 'foo.log' ] ],
);
π CAVEATS π
okay now the part where we keep it real. read this, bestie, it'll save you a headache π
- if your application has several different user agents, you will get debug output from all of them. this could get quite cluttered, ngl.
- since
LWP::ConsoleLogger::Everywheredoes its magic during compile time</>, it will most likely catch every user agent in your application β unless youuse LWP::ConsoleLogger::Everywhereinside a file that gets loaded at runtime. and if the user agent you wanted to debug had already been created by then, it can't hook into the constructor any more. tragic. - this module works by catching new user agents directly in
LWP::UserAgentwhen they're created. that way all the properly implemented sub classes likeWWW::Mechanizego through it too π«Ά. but if you run into one that installs its own handlers into the user agent after callingnewinLWP::UserAgent, that might overwrite the onesLWP::ConsoleLoggerinstalled. LWP::ConsoleLogger::Everywherekeeps references to every user agent ever created for the lifetime of your application. so if you've got a bunch of lexical user agents you recycle constantly, they won't actually go away and might eat memory π½οΈ. this is especially easy to hit withHTTP::Tiny, where the commonHTTP::Tiny->new->get(...)one-shot idiom creates a fresh logger on every single call.HTTP::Tinytraffic is only captured when the user agent is created viaHTTP::Tiny->new. class-method calls likeHTTP::Tiny->get(...)bypass the constructor and are not logged. also, becauseHTTP::Tiny->mirrorstreams the response body straight to a file, the body and text tables will be empty formirrorrequests.- the
HTTP::Tinypath has a few further limitations that theLWP::UserAgentandMojo::UserAgentpaths do not share:- redirect chains are collapsed.
HTTP::Tinyfollows redirects internally and only the final response is visible to the logger, so intermediate hops are not logged. the LWP andMojo::UserAgentpaths log each hop separately. - some headers that
HTTP::Tinyadds at the transport layer are reconstructed on a best-effort basis and may not exactly match what goes out on the wire. for example theConnectionheader and anAuthorizationheader synthesized fromuserinfoin the request URL are not reflected in the logged request. - cookie values are not redacted by the
LWPCL_REDACT_*environment variables. this is existing behaviour shared with the LWP andMojo::UserAgentpaths, and it's noted here so you don't mistake the logged output for a redacted view π.
- redirect chains are collapsed.
π SEE ALSO π
want more info, or want more detailed control? go see LWP::ConsoleLogger.
π AUTHOR π
Olaf Alders <olaf@wundercounter.com>
π COPYRIGHT AND LICENSE π
This software is Copyright (c) 2014 by MaxMind, Inc.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
and that's the whole page, bestie π«Ά generated by perl v5.42.3 on 2026-09-18 β go forth and trace every last user agent, you absolute legend β¨π
π¦ where this page comes from
- fedora 43: perl-LWP-ConsoleLogger 1.0.3-1.fc43 Β· Artistic-2.0
- fedora 44: perl-LWP-ConsoleLogger 1.0.3-1.fc44 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms