-
-
30 Nov 2020 00:21:36 UTC
- Distribution: Plack
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues (98)
- Testers (4618 / 10 / 0)
- Kwalitee
Bus factor: 1- 80.40% Coverage
- License: perl_5
- Perl: v5.8.1
- Activity
24 month- Tools
- Download (185.98KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 131 contributors- Tatsuhiko Miyagawa
-
Aaron Trevena
-
Ævar Arnfjörð Bjarmason
-
Akzhan Abdulin
-
Alexandr Ciornii
-
Alex J. G. Burzyński
-
Allan Whiteford
-
Andrew Fresh
-
Andrew Rodland
-
Andy Wardley
-
Aristotle Pagaltzis
-
Arthur Axel 'fREW' Schmidt
-
Asato Wakisaka
-
Ashley Pond V
-
Ask Bjørn Hansen
-
ben hengst
-
Ben Morrow
-
Bernhard Graf
-
Chad Granum
-
chansen
-
Chia-liang Kao
-
cho45
-
Christian Walde
-
chromatic
-
Cosimo Streppone
-
Dagfinn Ilmari Mannsåker
-
Daisuke Maki
-
Daisuke Murase
-
Dave Marr
-
Dave Rolsky
-
David E. Wheeler
-
David Schmidt
-
David Steinbrunner
-
dmaestro
-
Eduardo Arino de la Rubia
-
Emmanuel Seyman
-
Eric Johnson
-
Eugen Konkov
-
Fabrice Gabolde
-
fayland
-
Flavio Poletti
-
Florian Ragwitz
-
franck cuny
-
Gianni Ceccarelli
-
Graham Knop
-
Grant McLean
-
Hans Dieter Pearcey
-
Haruka Iwao
-
Henry Baragar
-
hiratara
-
HIROSE Masaaki
-
Hiroshi Sakai
-
Ian Bradley
-
Ian Burrell
-
Jakob Voss
-
Jay Hannah
-
Jesse Luehrs
-
Jiro Nishiguchi
-
Johannes Plunien
-
John Beppu
-
John Napiorkowski
-
Jonathan Swartz
-
José Pinheiro Neta
-
Justin Davis
-
kakuno
-
Kang-min Liu
-
Karen Etheridge
-
Kazuho Oku
-
Keedi Kim
-
Lee Aylward
-
Leo Lapworth
-
mala
-
Marco Pessotto
-
Marian Schubert
-
Mark Fowler
-
Mark Stosberg
-
Masahiro Chiba
-
Masahiro Nagano
-
Michael G. Schwern
-
Michal Josef Špaček
-
mickey
-
Narsimham Chelluri
-
Nick Wellnhofer
-
Nobuo Danjou
-
Olaf Alders
-
Oliver Gorwits
-
Oliver Paukstadt
-
Oliver Trosien
-
Olivier Mengué
-
osfameron
-
Panu Ervamaa
-
Paul Driver
-
Pedro Melo
-
Perlover
-
Peter Flanigan
-
Peter Makholm
-
Piotr Roszatycki
-
punytan
-
Rafael Kitover
-
Randy Stauner
-
Ray Miller
-
Richard Simões
-
Ricky Morse
-
Robert Rothenberg
-
Rob Hoelz
-
runarb
-
Ryo Miyake
-
Sawyer X
-
Scott S. McCoy
-
Shawn M Moore
-
Shoichi Kaji
-
smcmurray
-
Stephen Clouse
-
Stevan Little
-
Stuart A Johnston
-
Takeshi OKURA
-
The Dumb Terminal
-
Thomas Klausner
-
Thomas Sibley
-
Tim Bunce
-
Tokuhiro Matsuno
-
Tomas Doran
-
Tom Heady
-
vti
-
Wallace Reis
-
xaicron
-
Yann Kerherve
-
yappo
-
Yury Zavarin
-
Yuval Kogman
-
唐鳳
- Dependencies
- Apache::LogFormat::Compiler
- Cookie::Baker
- Devel::StackTrace
- Devel::StackTrace::AsHTML
- File::ShareDir
- Filesys::Notify::Simple
- HTTP::Entity::Parser
- HTTP::Headers::Fast
- HTTP::Message
- HTTP::Tiny
- Hash::MultiValue
- Pod::Usage
- Stream::Buffered
- Test::TCP
- Try::Tiny
- URI
- WWW::Form::UrlEncoded
- parent
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Plack::Middleware::AccessLog - Logs requests like Apache's log format
SYNOPSIS
# in app.psgi use Plack::Builder; builder { enable "Plack::Middleware::AccessLog", format => "combined"; $app; };
DESCRIPTION
Plack::Middleware::AccessLog forwards the request to the given app and logs request and response details to the logger callback. The format can be specified using Apache-like format strings (or
combined
orcommon
for the default formats). If none is specifiedcombined
is used.This middleware uses calculable Content-Length by checking body type, and cannot log the time taken to serve requests. It also logs the request before the response is actually sent to the client. Use Plack::Middleware::AccessLog::Timed if you want to log details after the response is transmitted (more like a real web server) to the client.
This middleware is enabled by default when you run plackup as a default
development
environment.CONFIGURATION
- format
-
enable "Plack::Middleware::AccessLog", format => '%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-agent}i"';
Takes a format string (or a preset template
combined
orcustom
) to specify the log format. This middleware uses Apache::LogFormat::Compiler to generate access_log lines. See more details on perldoc Apache::LogFormat::Compiler%% a percent sign %h REMOTE_ADDR from the PSGI environment, or - %l remote logname not implemented (currently always -) %u REMOTE_USER from the PSGI environment, or - %t [local timestamp, in default format] %r REQUEST_METHOD, REQUEST_URI and SERVER_PROTOCOL from the PSGI environment %s the HTTP status code of the response %b content length of the response %T custom field for handling times in subclasses %D custom field for handling sub-second times in subclasses %v SERVER_NAME from the PSGI environment, or - %V HTTP_HOST or SERVER_NAME from the PSGI environment, or - %p SERVER_PORT from the PSGI environment %P the worker's process id %m REQUEST_METHOD from the PSGI environment %U PATH_INFO from the PSGI environment %q QUERY_STRING from the PSGI environment %H SERVER_PROTOCOL from the PSGI environment
Some of these format fields are only supported by middleware that subclasses
AccessLog
.In addition, custom values can be referenced, using
%{name}
, with one of the mandatory modifier flagsi
,o
ort
:%{variable-name}i HTTP_VARIABLE_NAME value from the PSGI environment %{header-name}o header-name header in the response %{time-format]t localtime in the specified strftime format
- logger
-
my $logger = Log::Dispatch->new(...); enable "Plack::Middleware::AccessLog", logger => sub { $logger->log(level => 'debug', message => @_) };
Sets a callback to print log message to. It prints to the
psgi.errors
output stream by default. - char_handlers
-
my $handlers = { 'z' => sub { my ($env,$req) = @_; return $env->{HTTP_X_FORWARDED_FOR}; } }; enable "Plack::Middleware::AccessLog", format => '%z %{HTTP_X_FORWARDED_FOR|REMOTE_ADDR}Z', char_handlers => $handlers;
Takes a hash reference and passes it to the underlying Apache::LogFormat::Compiler's
char_handlers
. For more details see "ADD CUSTOM FORMAT STRING" in Apache::LogFormat::Compiler. - block_handlers
-
my $handlers = { 'Z' => sub { my ($block,$env,$req) = @_; # block eq 'HTTP_X_FORWARDED_FOR|REMOTE_ADDR' my ($main, $alt) = split('\|', $args); return exists $env->{$main} ? $env->{$main} : $env->{$alt}; } }; enable "Plack::Middleware::AccessLog", format => '%z %{HTTP_X_FORWARDED_FOR|REMOTE_ADDR}Z', block_handlers => $handlers;
Takes a hash reference and passes it to the underlying Apache::LogFormat::Compiler's
block_handlers
. For more details see "ADD CUSTOM FORMAT STRING" in Apache::LogFormat::Compiler.
AUTHORS
Tatsuhiko Miyagawa
Masahiro Nagano
SEE ALSO
Apache::LogFormat::Compiler, http://httpd.apache.org/docs/2.2/mod/mod_log_config.html Rack::CustomLogger
Module Install Instructions
To install Plack, copy and paste the appropriate command in to your terminal.
cpanm Plack
perl -MCPAN -e shell install Plack
For more information on module installation, please visit the detailed CPAN module installation guide.