instiki/vendor/plugins/rack/doc/classes/Rack/CommonLogger.html
Jacques Distler 4e14ccc74d Instiki 0.16.3: Rails 2.3.0
Instiki now runs on the Rails 2.3.0 Candidate Release.
Among other improvements, this means that it now 
automagically selects between WEBrick and Mongrel.

Just run

    ./instiki --daemon
2009-02-04 14:26:08 -06:00

308 lines
13 KiB
HTML

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Class: Rack::CommonLogger</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
<script type="text/javascript">
// <![CDATA[
function popupCode( url ) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
function toggleCode( id ) {
if ( document.getElementById )
elem = document.getElementById( id );
else if ( document.all )
elem = eval( "document.all." + id );
else
return false;
elemStyle = elem.style;
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
elemStyle.display = "none"
}
return true;
}
// Make codeblocks hidden by default
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
// ]]>
</script>
</head>
<body>
<div id="classHeader">
<table class="header-table">
<tr class="top-aligned-row">
<td><strong>Class</strong></td>
<td class="class-name-in-header">Rack::CommonLogger</td>
</tr>
<tr class="top-aligned-row">
<td><strong>In:</strong></td>
<td>
<a href="../../files/lib/rack/commonlogger_rb.html">
lib/rack/commonlogger.rb
</a>
<br />
</td>
</tr>
<tr class="top-aligned-row">
<td><strong>Parent:</strong></td>
<td>
Object
</td>
</tr>
</table>
</div>
<!-- banner header -->
<div id="bodyContent">
<div id="contextContent">
<div id="description">
<p>
<a href="CommonLogger.html">Rack::CommonLogger</a> forwards every request
to an <tt>app</tt> given, and logs a line in the Apache common log format
to the <tt>logger</tt>, or rack.errors by default.
</p>
</div>
</div>
<div id="method-list">
<h3 class="section-bar">Methods</h3>
<div class="name-list">
<a href="#M000196">&lt;&lt;</a>&nbsp;&nbsp;
<a href="#M000194">_call</a>&nbsp;&nbsp;
<a href="#M000193">call</a>&nbsp;&nbsp;
<a href="#M000195">close</a>&nbsp;&nbsp;
<a href="#M000197">each</a>&nbsp;&nbsp;
<a href="#M000192">new</a>&nbsp;&nbsp;
</div>
</div>
</div>
<!-- if includes -->
<div id="section">
<!-- if method_list -->
<div id="methods">
<h3 class="section-bar">Public Class methods</h3>
<div id="method-M000192" class="method-detail">
<a name="M000192"></a>
<div class="method-heading">
<a href="#M000192" class="method-signature">
<span class="method-name">new</span><span class="method-args">(app, logger=nil)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000192-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000192-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/commonlogger.rb, line 7</span>
7: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">app</span>, <span class="ruby-identifier">logger</span>=<span class="ruby-keyword kw">nil</span>)
8: <span class="ruby-ivar">@app</span> = <span class="ruby-identifier">app</span>
9: <span class="ruby-ivar">@logger</span> = <span class="ruby-identifier">logger</span>
10: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<h3 class="section-bar">Public Instance methods</h3>
<div id="method-M000196" class="method-detail">
<a name="M000196"></a>
<div class="method-heading">
<a href="#M000196" class="method-signature">
<span class="method-name">&lt;&lt;</span><span class="method-args">(str)</span>
</a>
</div>
<div class="method-description">
<p>
By default, log to rack.errors.
</p>
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000196-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000196-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/commonlogger.rb, line 29</span>
29: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&lt;&lt;</span>(<span class="ruby-identifier">str</span>)
30: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;rack.errors&quot;</span>].<span class="ruby-identifier">write</span>(<span class="ruby-identifier">str</span>)
31: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;rack.errors&quot;</span>].<span class="ruby-identifier">flush</span>
32: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000194" class="method-detail">
<a name="M000194"></a>
<div class="method-heading">
<a href="#M000194" class="method-signature">
<span class="method-name">_call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000194-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000194-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/commonlogger.rb, line 16</span>
16: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">_call</span>(<span class="ruby-identifier">env</span>)
17: <span class="ruby-ivar">@env</span> = <span class="ruby-identifier">env</span>
18: <span class="ruby-ivar">@logger</span> <span class="ruby-operator">||=</span> <span class="ruby-keyword kw">self</span>
19: <span class="ruby-ivar">@time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
20: <span class="ruby-ivar">@status</span>, <span class="ruby-ivar">@header</span>, <span class="ruby-ivar">@body</span> = <span class="ruby-ivar">@app</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
21: [<span class="ruby-ivar">@status</span>, <span class="ruby-ivar">@header</span>, <span class="ruby-keyword kw">self</span>]
22: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000193" class="method-detail">
<a name="M000193"></a>
<div class="method-heading">
<a href="#M000193" class="method-signature">
<span class="method-name">call</span><span class="method-args">(env)</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000193-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000193-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/commonlogger.rb, line 12</span>
12: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">env</span>)
13: <span class="ruby-identifier">dup</span>.<span class="ruby-identifier">_call</span>(<span class="ruby-identifier">env</span>)
14: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000195" class="method-detail">
<a name="M000195"></a>
<div class="method-heading">
<a href="#M000195" class="method-signature">
<span class="method-name">close</span><span class="method-args">()</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000195-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000195-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/commonlogger.rb, line 24</span>
24: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">close</span>
25: <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:close</span>
26: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
<div id="method-M000197" class="method-detail">
<a name="M000197"></a>
<div class="method-heading">
<a href="#M000197" class="method-signature">
<span class="method-name">each</span><span class="method-args">() {|part| ...}</span>
</a>
</div>
<div class="method-description">
<p><a class="source-toggle" href="#"
onclick="toggleCode('M000197-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000197-source">
<pre>
<span class="ruby-comment cmt"># File lib/rack/commonlogger.rb, line 34</span>
34: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each</span>
35: <span class="ruby-identifier">length</span> = <span class="ruby-value">0</span>
36: <span class="ruby-ivar">@body</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">part</span><span class="ruby-operator">|</span>
37: <span class="ruby-identifier">length</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">part</span>.<span class="ruby-identifier">size</span>
38: <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">part</span>
39: }
40:
41: <span class="ruby-ivar">@now</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
42:
43: <span class="ruby-comment cmt"># Common Log Format: http://httpd.apache.org/docs/1.3/logs.html#common</span>
44: <span class="ruby-comment cmt"># lilith.local - - [07/Aug/2006 23:58:02] &quot;GET / HTTP/1.1&quot; 500 -</span>
45: <span class="ruby-comment cmt"># %{%s - %s [%s] &quot;%s %s%s %s&quot; %d %s\n} %</span>
46: <span class="ruby-ivar">@logger</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">%{%s - %s [%s] &quot;%s %s%s %s&quot; %d %s %0.4f\n}</span> <span class="ruby-operator">%</span>
47: [
48: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">'HTTP_X_FORWARDED_FOR'</span>] <span class="ruby-operator">||</span> <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;REMOTE_ADDR&quot;</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;-&quot;</span>,
49: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;REMOTE_USER&quot;</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;-&quot;</span>,
50: <span class="ruby-ivar">@now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-value str">&quot;%d/%b/%Y %H:%M:%S&quot;</span>),
51: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;REQUEST_METHOD&quot;</span>],
52: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;PATH_INFO&quot;</span>],
53: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;QUERY_STRING&quot;</span>].<span class="ruby-identifier">empty?</span> <span class="ruby-value">? </span><span class="ruby-value str">&quot;&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-value str">&quot;?&quot;</span><span class="ruby-operator">+</span><span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;QUERY_STRING&quot;</span>],
54: <span class="ruby-ivar">@env</span>[<span class="ruby-value str">&quot;HTTP_VERSION&quot;</span>],
55: <span class="ruby-ivar">@status</span>.<span class="ruby-identifier">to_s</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">3</span>],
56: (<span class="ruby-identifier">length</span>.<span class="ruby-identifier">zero?</span> <span class="ruby-value">? </span><span class="ruby-value str">&quot;-&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">length</span>.<span class="ruby-identifier">to_s</span>),
57: <span class="ruby-ivar">@now</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@time</span>
58: ]
59: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="validator-badges">
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>
</body>
</html>