Andrew Rodland > Catalyst-Plugin-AccessLog-1.05 > Catalyst::Plugin::AccessLog::Formatter

Download:
Catalyst-Plugin-AccessLog-1.05.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 1.05   Source  

NAME ^

Catalyst::Plugin::AccessLog::Formatter - Log formatter for Catalyst::Plugin::AccessLog

VERSION ^

version 1.05

DESCRIPTION ^

The log format argument is a string which will be used to generate each line of the access log. The string consists of literal characters which will be copied to the log output verbatim, and escapes, which will be replaced with information about the request or the response. This format string is intended to be compatible with the Apache LogFormat directive, however it contains some extensions and leaves a few features unimplemented.

Escapes can be either short escapes or long escapes. Both types begin with the "%" character. Short escapes consist of a % followed by a single character, for example %h for the remote hostname. Long escapes consist of a % followed by a name inside square brackets, for example %[remote_hostname] for the same option. Apache-compatible options have both short escapes and long escapes, while incompatible options have only long escapes. For compatibility, short escapes may have a "redirection specifier" < or > inserted after the %, e.g. %>s as used in the default Combined log format, but this does nothing, as this module has no support for tracking sub-requests.

Some escapes (currently %[time], %[apache_time], %[header], and %[apache_header]) may also take an argument, which can be optional or required. The argument is placed inside curly braces between the percent sign and the name of the escape, for example %{User-agent}i or %{User-agent}[header] to get the value of the User-agent header.

A literal percent-sign can be produced in the output using the escape sequence %%.

Configuration

The following are optional arguments passed to Catalyst::Plugin::AccessLog::Formatter->new. Ordinarily these values will be provided by Catalyst::Plugin::AccessLog from its formatter config hash.

format

Default: '%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"' (Apache common log format).

The format string for each line of output. You can use Apache LogFormat strings, with a reasonably good level of compatibility, or you can use a slightly more readable format. The log format is documented in detail in Catalyst::Plugin::AccessLog::Formatter.

time_format

Default: '%Y-%m-%dT%H:%M:%S' (ISO 8601)

The default time format for the %t / %[time] escape. This is a strftime format string, which will be provided to DateTime's strftime method.

time_zone

Default: local

The timezone to use when printing times in access logs. This will be passed to DateTime::TimeZone's constructor. Olson timezone names, POSIX TZ values, and the keywords "local" and "UTC" are reasonable choices.

hostname_lookups

Default: false

If this option is set to a true value, then the %h / %[remote_hostname] escape will resolve the client IP address using reverse DNS. This is generally not recommended for reasons of performance and security. Equivalent to the Apache option HostnameLookups.

Escapes

%[remote_address], %a

The IP address of the remote client.

%[clf_size], %b

The size of the response content in bytes. If the response content is empty, produces a dash - instead of 0. This is compatible with CLF.

%[size], %B

The size of the response content in bytes. Always numeric, even for 0.

%[remote_host], %h

The hostname of the remote client, if the hostname_lookups config option is true. Otherwise, the IP address of the remote client, as %[remote_address].

%[header], %i

The value of the request header named in the (mandatory) argument, or "-" if no such header was provided. Usage: %{User-agent}i to get the User-agent request header.

%l

For Apache compatibility, this option produces a single dash -. In Apache this option returns the remote username from an ident check, if the module is present, which it never is, which means it always produces a single dash on Apache as well. We don't bother implementing ident.

%[method], %m

The request method (e.g. GET, POST).

%[port], %p

The port number that the request was received on. In apache this is the server's "canonical port", however this is information that's not available to Catalyst.

%[query], %q

The query string (beginning with a ? if there is a query string, otherwise an empty string).

%[request_line], %r

The first line of the HTTP request, e.g. "GET / HTTP/1.0".

%[status], %s

The HTTP status of the response, e.g. 200 or 404.

%[apache_time], %t

The time that the request was received.

While this escape and the %[time] escape both take an optional strftime argument, they differ in their default formats. This escape defaults to a "human readable" format which is lousy to parse, but is nonetheless compatible with apache.

%[time], %[datetime]

The time that the request was received.

While this escape and the %[apache_time] escape both take an optional strftime argument, they differ in their default formats. This escape defaults to the time_format config option passed to the constructor. If that option is not provided, the default is ISO 8601.

%[remote_user], %u

The REMOTE_USER variable as set by HTTP basic auth, or certain frontend authentication methods. Returns a dash - if no such thing exists.

%[host_port], %v, %V

The host and the port of the request URI. Apache specifies that these should be the server's "canonical" host and port, but this information is unavailable to Catalyst.

%[hostname]

The hostname of the request URI.

%[path], %U

The request path (relative to the application root, but with a leading slash).

%[handle_time], %T

The time spent handling this request, as provided by the $c->stats object. Returns a dash - if stats are unavailable.

%[action]

The private path of the Catalyst action that handled the request.

%[sessionid]

The session ID, if there is one, otherwise "-".

%[userid]

The user ID, if Authentication is enabled and a user exists, otherwise "-"

%[request_count]

The request count for the current process, as displayed in debug info.

%[pid]

The process ID of the instance handling the request.

AUTHORS ^

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2012 by Andrew Rodland.

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

syntax highlighting: