Subversion Info

Rev
406
Last Checked In
2007-07-18 17:01:59 (7 months ago)
Checked in by
bbleything

Methods

Class Index

Quicksearch

Arrow::Logger::FileOutputter

This is an Arrow::Logger::Outputter that writes to an IO object.

Constants

SVNRev
SVN Revision
SVNId
SVN Id
DefaultDescription
The default description
DefaultFormat
The default format (copied from the superclass)

Attributes

io[RW]
The filehandle open to the logfile

Public Class Methods

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

Create a new Arrow::Logger::FileOutputter object. The io argument can be an IO or StringIO object, in which case output is sent to it directly, a String, in which case it is used as the first argument to File.open, or an Integer file descriptor, in which case a new IO object is created which appends to the file handle matching that descriptor.

    # File lib/arrow/logger/fileoutputter.rb, line 51
51:     def initialize( uri, description=DefaultDescription, format=DefaultFormat )
52:         if uri.hierarchical?
53:             @io = File.open( uri.path, File::WRONLY|File::CREAT )
54:         else
55:             case uri.opaque
56:             when /(std|def)err/i
57:                 @io = $deferr
58:             when /(std|def)out/i
59:                 @io = $defout
60:             when /^(\d+)$/
61:                 @io = IO.for_fd( Integer($1), "w" )
62:             else
63:                 raise "Unrecognized log URI '#{uri}'"
64:             end
65:         end
66: 
67:         super
68:     end

Public Instance Methods

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

Write the given level, name, frame, and msg to the logfile.

    # File lib/arrow/logger/fileoutputter.rb, line 80
80:     def write( time, level, name, frame, msg )
81:         if block_given?
82:             super
83:         else
84:             super {|msg| @io.puts(msg) }
85:         end
86:     end

secsequence

--- SEC00067

seccomment

--- ""

attributes

--- 
- name: io
  rw: RW
  a_desc: |+
    
    The filehandle open to the logfile
    

method_list

--- 
- methods: 
  - visibility: public
    aref: M000192
    name: new
    sourcecode: "    <span class=\"ruby-comment cmt\"># File lib/arrow/logger/fileoutputter.rb, line 51</span>\n\
      51:     <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\
      52:         <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">uri</span>.<span class=\"ruby-identifier\">hierarchical?</span>\n\
      53:             <span class=\"ruby-ivar\">@io</span> = <span class=\"ruby-constant\">File</span>.<span class=\"ruby-identifier\">open</span>( <span class=\"ruby-identifier\">uri</span>.<span class=\"ruby-identifier\">path</span>, <span class=\"ruby-constant\">File</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">WRONLY</span><span class=\"ruby-operator\">|</span><span class=\"ruby-constant\">File</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">CREAT</span> )\n\
      54:         <span class=\"ruby-keyword kw\">else</span>\n\
      55:             <span class=\"ruby-keyword kw\">case</span> <span class=\"ruby-identifier\">uri</span>.<span class=\"ruby-identifier\">opaque</span>\n\
      56:             <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-regexp re\">/(std|def)err/i</span>\n\
      57:                 <span class=\"ruby-ivar\">@io</span> = <span class=\"ruby-identifier\">$deferr</span>\n\
      58:             <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-regexp re\">/(std|def)out/i</span>\n\
      59:                 <span class=\"ruby-ivar\">@io</span> = <span class=\"ruby-identifier\">$defout</span>\n\
      60:             <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-regexp re\">/^(\\d+)$/</span>\n\
      61:                 <span class=\"ruby-ivar\">@io</span> = <span class=\"ruby-constant\">IO</span>.<span class=\"ruby-identifier\">for_fd</span>( <span class=\"ruby-constant\">Integer</span>(<span class=\"ruby-identifier\">$1</span>), <span class=\"ruby-value str\">&quot;w&quot;</span> )\n\
      62:             <span class=\"ruby-keyword kw\">else</span>\n\
      63:                 <span class=\"ruby-identifier\">raise</span> <span class=\"ruby-node\">&quot;Unrecognized log URI '#{uri}'&quot;</span>\n\
      64:             <span class=\"ruby-keyword kw\">end</span>\n\
      65:         <span class=\"ruby-keyword kw\">end</span>\n\
      66: \n\
      67:         <span class=\"ruby-keyword kw\">super</span>\n\
      68:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Create a <a href="FileOutputter.html#M000192">new</a> <a
      href="FileOutputter.html">Arrow::Logger::FileOutputter</a> object. The
      <tt>io</tt> argument can be an IO or StringIO object, in which case output
      is sent to it directly, a <a href="../../String.html">String</a>, in which
      case it is used as the first argument to File.open, or an <a
      href="../../Integer.html">Integer</a> file descriptor, in which case a <a
      href="FileOutputter.html#M000192">new</a> IO object is created which
      appends to the file handle matching that descriptor.
      </p>
    params: ( uri, description=DefaultDescription, format=DefaultFormat )
  category: Class
  type: Public
- methods: 
  - visibility: public
    aref: M000193
    name: write
    sourcecode: "    <span class=\"ruby-comment cmt\"># File lib/arrow/logger/fileoutputter.rb, line 80</span>\n\
      80:     <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\
      81:         <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">block_given?</span>\n\
      82:             <span class=\"ruby-keyword kw\">super</span>\n\
      83:         <span class=\"ruby-keyword kw\">else</span>\n\
      84:             <span class=\"ruby-keyword kw\">super</span> {<span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">msg</span><span class=\"ruby-operator\">|</span> <span class=\"ruby-ivar\">@io</span>.<span class=\"ruby-identifier\">puts</span>(<span class=\"ruby-identifier\">msg</span>) }\n\
      85:         <span class=\"ruby-keyword kw\">end</span>\n\
      86:     <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 logfile.
      </p>
    params: ( time, level, name, frame, msg )
  category: Instance
  type: Public

sectitle

--- 

constants

--- 
- name: SVNRev
  desc: |+
    
    SVN Revision
    
  value: "%q$Rev: 406 $"
- name: SVNId
  desc: |+
    
    SVN Id
    
  value: "%q$Id: fileoutputter.rb 406 2007-07-18 17:01:59Z bbleything $"
- name: DefaultDescription
  desc: |+
    
    The default description
    
  value: "&quot;File Outputter&quot;"
- name: DefaultFormat
  desc: |+
    
    The default format (copied from the superclass)
    
  value: Arrow::Logger::Outputter::DefaultFormat

[Validate]

Generated with the Darkfish Rdoc Generator.