Subversion Info

Rev
439
Last Checked In
2008-04-10 23:27:34 (6 days ago)
Checked in by
deveiant

Methods

Class Index

Quicksearch

Arrow::Logger::ApacheOutputter

Instances of this class write log messages of the corresponding error level to the Apache log.

Constants

SVNRev
SVN Revision
SVNId
SVN Id
DefaultDescription
The default description
DefaultFormat
The default interpolatable string that‘s used to build the message to output
LEVELS
The Logger log levels (copied for easy access)

Public Class Methods

new( uri, description=DefaultDescription, format=DefaultFormat ) click to toggle source

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

Public Instance Methods

write( time, level, name, frame, msg ) click to toggle source

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

secsequence

--- SEC00064

seccomment

--- ""

method_list

--- 
- 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\">&gt;=</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\">&quot;log_#{level}&quot;</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

sectitle

--- 

constants

--- 
- 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: "&quot;Apache Log Outputter&quot;"
- name: DefaultFormat
  desc: |+
    
    The default interpolatable string that&#8216;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

[Validate]

Generated with the Darkfish Rdoc Generator.