Class: Arrow::Logger::Outputter
- Inherits:
 - 
      Object
      
        
- Object
 - Arrow::Logger::Outputter
 
 - Includes:
 - PluginFactory
 - Defined in:
 - lib/arrow/logger/outputter.rb
 
Overview
The Arrow::Logger::Outputter class, which is the abstract base class for objects that control where logging output is sent in an Arrow::Logger object.
Authors
Michael Granger
Please see the file LICENSE in the top-level directory for licensing details.
Direct Known Subclasses
Constant Summary
- DEFAULT_DESCRIPTION =
          
The default description
 "Logging Outputter"- DEFAULT_FORMAT =
          
The default interpolatable string that’s used to build the message to output
 %q{#{time.strftime('%Y/%m/%d %H:%M:%S')} [#{level}]: #{name} } + %q{#{frame ? '('+frame+')' : ''}: #{msg[0,1024]}}
Instance Attribute Summary
- 
  
    
      - (Object) description 
    
    
  
  
  
    
    
  
  
  
  
  
    
The outputter’s description, for introspection utilities.
 - 
  
    
      - (Object) format 
    
    
  
  
  
    
    
  
  
  
  
  
    
The uninterpolated string format for this outputter.
 
Class Method Summary
- 
  
    
      + (Object) create(uri, *args) 
    
    
  
  
  
  
  
  
  
    
Create a new Arrow::Logger::Outputter object of the type specified by uri.
 - 
  
    
      + (Object) derivativeDirs 
    
    
  
  
  
  
  
  
  
    
Specify the directory to look for the derivatives of this class in.
 - 
  
    
      + (Object) parse_uri(str) 
    
    
  
  
  
  
  
  
  
    
Parse the given string into a URI object, appending the path part if it doesn’t exist.
 
Instance Method Summary
- 
  
    
      - (Outputter) initialize(uri, description = DEFAULT_DESCRIPTION, format = DEFAULT_FORMAT) 
    
    
  
  
    constructor
  
  
  
  
  
  
    
Create a new Arrow::Logger::Outputter object with the given uri, description and sprintf-style format.
 - 
  
    
      - (Object) inspect 
    
    
  
  
  
  
  
  
  
    
Returns a human-readable description of the object as a String.
 - 
  
    
      - (Object) inspection_details 
    
    
  
  
  
  protected
  
  
  
    
Returns a String which should be included in the implementation-specific part of the object’s inspection String.
 - 
  
    
      - (Object) write(time, level, name, frame, msg) 
    
    
  
  
  
  
  
  
  
    
Write the given level, name, frame, and msg to the target output mechanism.
 
Constructor Details
- (Outputter) initialize(uri, description = DEFAULT_DESCRIPTION, format = DEFAULT_FORMAT)
Create a new Arrow::Logger::Outputter object with the given uri, description and sprintf-style format.
      65 66 67 68  | 
    
      # File 'lib/arrow/logger/outputter.rb', line 65 def initialize( uri, description=DEFAULT_DESCRIPTION, format=DEFAULT_FORMAT ) @description = description @format = format end  | 
  
Instance Attribute Details
- (Object) description
The outputter’s description, for introspection utilities.
      76 77 78  | 
    
      # File 'lib/arrow/logger/outputter.rb', line 76 def description @description end  | 
  
- (Object) format
The uninterpolated string format for this outputter. This message written will be formed by interpolating this string in the #write method’s context immediately before outputting.
      81 82 83  | 
    
      # File 'lib/arrow/logger/outputter.rb', line 81 def format @format end  | 
  
Class Method Details
+ (Object) create(uri, *args)
Create a new Arrow::Logger::Outputter object of the type specified by uri.
      52 53 54 55  | 
    
      # File 'lib/arrow/logger/outputter.rb', line 52 def self::create( uri, *args ) uri = self.parse_uri( uri ) if uri.is_a?( String ) super( uri.scheme.dup, uri, *args ) end  | 
  
+ (Object) derivativeDirs
Specify the directory to look for the derivatives of this class in.
      36 37 38  | 
    
      # File 'lib/arrow/logger/outputter.rb', line 36 def self::derivativeDirs ["arrow/logger"] end  | 
  
+ (Object) parse_uri(str)
Parse the given string into a URI object, appending the path part if it doesn’t exist.
      43 44 45 46 47  | 
    
      # File 'lib/arrow/logger/outputter.rb', line 43 def self::parse_uri( str ) return str if str.is_a?( URI::Generic ) str += ":." if str.match( /^\w+$/ ) URI.parse( str ) end  | 
  
Instance Method Details
- (Object) inspect
Returns a human-readable description of the object as a String
      101 102 103 104 105 106 107  | 
    
      # File 'lib/arrow/logger/outputter.rb', line 101 def inspect "#<%s:0x%0x %s>" % [ self.class.name, self.object_id * 2, self.inspection_details, ] end  | 
  
- (Object) inspection_details (protected)
Returns a String which should be included in the implementation-specific part of the object’s inspection String.
      116 117 118  | 
    
      # File 'lib/arrow/logger/outputter.rb', line 116 def inspection_details return "%s (%s)" % [ self.description, self.format ] end  | 
  
- (Object) write(time, level, name, frame, msg)
Write the given level, name, frame, and msg to the target output mechanism. Subclasses can call this with a block which will be passed the formatted message. If no block is supplied by the child, this method will check to see if $DEBUG is set, and if it is, write the log message to $stderr.
      89 90 91 92 93 94 95 96 97  | 
    
      # File 'lib/arrow/logger/outputter.rb', line 89 def write( time, level, name, frame, msg ) msg = @format.interpolate( binding ) if block_given? yield( msg ) else $stderr.puts( msg ) if $DEBUG end end  |