Subversion Info

Rev
437
Last Checked In
2008-03-28 00:49:20 (2 weeks ago)
Checked in by
deveiant

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 /Users/ged/source/ruby/Arrow/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 /Users/ged/source/ruby/Arrow/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

Protected Instance Methods

inspection_details() click to toggle source

Returns a String which should be included in the implementation-specific part of the object‘s inspection String.

     # File /Users/ged/source/ruby/Arrow/lib/arrow/logger/fileoutputter.rb, line 95
 95:     def inspection_details
 96:         io_desc = 
 97:             case @io
 98:             when $stderr
 99:                 'STDERR'
100:             when $stdout
101:                 'STDOUT'
102:             when StringIO
103:                 '(StringIO 0x%0x)' % [ @io.object_id * 2 ]
104:             else
105:                 '(IO: fd %d)' % [ @io.fileno ]
106:             end
107:         
108:         return [ super, io_desc ].join(', ')
109:     end

secsequence

--- SEC00068

seccomment

--- ""

attributes

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

method_list

--- 
- methods: 
  - visibility: public
    aref: M000196
    name: new
    sourcecode: "    <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/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#M000196">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 String, 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#M000196">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: M000197
    name: write
    sourcecode: "    <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/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
- methods: 
  - visibility: protected
    aref: M000198
    name: inspection_details
    sourcecode: "     <span class=\"ruby-comment cmt\"># File /Users/ged/source/ruby/Arrow/lib/arrow/logger/fileoutputter.rb, line 95</span>\n 95:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">inspection_details</span>\n 96:         <span class=\"ruby-identifier\">io_desc</span> = \n 97:             <span class=\"ruby-keyword kw\">case</span> <span class=\"ruby-ivar\">@io</span>\n 98:             <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-identifier\">$stderr</span>\n 99:                 <span class=\"ruby-value str\">'STDERR'</span>\n\
      100:             <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-identifier\">$stdout</span>\n\
      101:                 <span class=\"ruby-value str\">'STDOUT'</span>\n\
      102:             <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-constant\">StringIO</span>\n\
      103:                 <span class=\"ruby-value str\">'(StringIO 0x%0x)'</span> <span class=\"ruby-operator\">%</span> [ <span class=\"ruby-ivar\">@io</span>.<span class=\"ruby-identifier\">object_id</span> <span class=\"ruby-operator\">*</span> <span class=\"ruby-value\">2</span> ]\n\
      104:             <span class=\"ruby-keyword kw\">else</span>\n\
      105:                 <span class=\"ruby-value str\">'(IO: fd %d)'</span> <span class=\"ruby-operator\">%</span> [ <span class=\"ruby-ivar\">@io</span>.<span class=\"ruby-identifier\">fileno</span> ]\n\
      106:             <span class=\"ruby-keyword kw\">end</span>\n\
      107:         \n\
      108:         <span class=\"ruby-keyword kw\">return</span> [ <span class=\"ruby-keyword kw\">super</span>, <span class=\"ruby-identifier\">io_desc</span> ].<span class=\"ruby-identifier\">join</span>(<span class=\"ruby-value str\">', '</span>)\n\
      109:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Returns a String which should be included in the implementation-specific
      part of the object&#8216;s inspection String.
      </p>
    params: ()
  category: Instance
  type: Protected

sectitle

--- 

constants

--- 
- name: SVNRev
  desc: |+
    
    SVN Revision
    
  value: "%q$Rev: 437 $"
- name: SVNId
  desc: |+
    
    SVN Id
    
  value: "%q$Id: fileoutputter.rb 437 2008-03-28 00:49:20Z deveiant $"
- 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.