Instances of this class write log messages of the corresponding error level to the Apache log.
Create a new Arrow::Logger::ApacheOutputter object that will write to the apache log, and use the given description and format.
# File /Users/ged/source/ruby/Arrow/lib/arrow/logger/apacheoutputter.rb, line 54
54: def initialize( uri, description=DefaultDescription, format=DefaultFormat )
55: super
56: end
Write the given level, name, frame, and msg to the target output mechanism.
# File /Users/ged/source/ruby/Arrow/lib/arrow/logger/apacheoutputter.rb, line 65
65: def write( time, level, name, frame, msg )
66: return unless defined?( ::Apache )
67: srvr = ::Apache.request.server
68: return unless srvr.loglevel >= LEVELS[ level ]
69:
70: # Translate calls to log.warning into Apache::Server#log_warn
71: level = :warn if level == :warning
72:
73: logMethod = srvr.method( "log_#{level}" )
74: super {|msg|
75: # Escape any unexpanded sprintf format patterns
76: msg.gsub!( /%/, '%%' )
77: logMethod.call( msg )
78: }
79: end
--- SEC00064
--- ""
---
- methods:
- visibility: public
aref: M000185
name: new
sourcecode: " <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/logger/apacheoutputter.rb, line 54</span>\n\
54: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">initialize</span>( <span class=\"ruby-identifier\">uri</span>, <span class=\"ruby-identifier\">description</span>=<span class=\"ruby-constant\">DefaultDescription</span>, <span class=\"ruby-identifier\">format</span>=<span class=\"ruby-constant\">DefaultFormat</span> )\n\
55: <span class=\"ruby-keyword kw\">super</span>\n\
56: <span class=\"ruby-keyword kw\">end</span>"
m_desc: |-
<p>
Create a <a href="ApacheOutputter.html#M000185">new</a> <a
href="ApacheOutputter.html">Arrow::Logger::ApacheOutputter</a> object that
will <a href="ApacheOutputter.html#M000186">write</a> to the apache log,
and use the given <tt>description</tt> and <tt>format</tt>.
</p>
params: ( uri, description=DefaultDescription, format=DefaultFormat )
category: Class
type: Public
- methods:
- visibility: public
aref: M000186
name: write
sourcecode: " <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/logger/apacheoutputter.rb, line 65</span>\n\
65: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">write</span>( <span class=\"ruby-identifier\">time</span>, <span class=\"ruby-identifier\">level</span>, <span class=\"ruby-identifier\">name</span>, <span class=\"ruby-identifier\">frame</span>, <span class=\"ruby-identifier\">msg</span> )\n\
66: <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-keyword kw\">unless</span> <span class=\"ruby-keyword kw\">defined?</span>( <span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Apache</span> )\n\
67: <span class=\"ruby-identifier\">srvr</span> = <span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Apache</span>.<span class=\"ruby-identifier\">request</span>.<span class=\"ruby-identifier\">server</span>\n\
68: <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-keyword kw\">unless</span> <span class=\"ruby-identifier\">srvr</span>.<span class=\"ruby-identifier\">loglevel</span> <span class=\"ruby-operator\">>=</span> <span class=\"ruby-constant\">LEVELS</span>[ <span class=\"ruby-identifier\">level</span> ]\n\
69: \n\
70: <span class=\"ruby-comment cmt\"># Translate calls to log.warning into Apache::Server#log_warn</span>\n\
71: <span class=\"ruby-identifier\">level</span> = <span class=\"ruby-identifier\">:warn</span> <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">level</span> <span class=\"ruby-operator\">==</span> <span class=\"ruby-identifier\">:warning</span>\n\
72: \n\
73: <span class=\"ruby-identifier\">logMethod</span> = <span class=\"ruby-identifier\">srvr</span>.<span class=\"ruby-identifier\">method</span>( <span class=\"ruby-node\">"log_#{level}"</span> )\n\
74: <span class=\"ruby-keyword kw\">super</span> {<span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">msg</span><span class=\"ruby-operator\">|</span>\n\
75: <span class=\"ruby-comment cmt\"># Escape any unexpanded sprintf format patterns</span>\n\
76: <span class=\"ruby-identifier\">msg</span>.<span class=\"ruby-identifier\">gsub!</span>( <span class=\"ruby-regexp re\">/%/</span>, <span class=\"ruby-value str\">'%%'</span> )\n\
77: <span class=\"ruby-identifier\">logMethod</span>.<span class=\"ruby-identifier\">call</span>( <span class=\"ruby-identifier\">msg</span> )\n\
78: }\n\
79: <span class=\"ruby-keyword kw\">end</span>"
m_desc: |-
<p>
Write the given <tt>level</tt>, <tt>name</tt>, <tt>frame</tt>, and
<tt>msg</tt> to the target output mechanism.
</p>
params: ( time, level, name, frame, msg )
category: Instance
type: Public
---
---
- name: SVNRev
desc: |+
SVN Revision
value: "%q$Rev: 439 $"
- name: SVNId
desc: |+
SVN Id
value: "%q$Id: apacheoutputter.rb 439 2008-04-10 23:27:34Z deveiant $"
- name: DefaultDescription
desc: |+
The default description
value: ""Apache Log Outputter""
- name: DefaultFormat
desc: |+
The default interpolatable string that‘s used to build the message to
output
value: "%q{#{name}#{frame ? '('+frame+')' : ''}: #{msg[0,2048]}}"
- name: LEVELS
desc: |+
The <a href="../Logger.html">Logger</a> log levels (copied for easy access)
value: Arrow::Logger::LEVELS
Generated with the Darkfish Rdoc Generator.