Class: Rex::Logging::Sinks::Stream
- Inherits:
 - 
      Object
      
        
- Object
 - Rex::Logging::Sinks::Stream
 
 
- Includes:
 - LogSink
 
- Defined in:
 - lib/rex/logging/sinks/stream.rb
 
Overview
This class implements the LogSink interface and backs it against a stream
Direct Known Subclasses
Instance Attribute Summary collapse
- 
  
    
      #stream  ⇒ Object 
    
    
  
  
  
  
    
    
  
  protected
  
  
  
  
    
:nodoc:.
 
Instance Method Summary collapse
- 
  
    
      #cleanup  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
:nodoc:.
 - 
  
    
      #initialize(stream)  ⇒ Stream 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Stream.
 - 
  
    
      #log(sev, src, level, msg)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Writes log data to a stream.
 - 
  
    
      #log_code_for(sev)  ⇒ Object 
    
    
  
  
  
  
  protected
  
  
  
  
    
This method returns the corresponding log code for the given severity.
 
Methods included from LogSink
Constructor Details
#initialize(stream) ⇒ Stream
Returns a new instance of Stream.
      16 17 18  | 
    
      # File 'lib/rex/logging/sinks/stream.rb', line 16 def initialize(stream) @stream = stream end  | 
  
Instance Attribute Details
#stream ⇒ Object (protected)
:nodoc:
      39 40 41  | 
    
      # File 'lib/rex/logging/sinks/stream.rb', line 39 def stream @stream end  | 
  
Instance Method Details
#cleanup ⇒ Object
:nodoc:
      33 34 35  | 
    
      # File 'lib/rex/logging/sinks/stream.rb', line 33 def cleanup # :nodoc: stream.close end  | 
  
#log(sev, src, level, msg) ⇒ Object
Writes log data to a stream
      23 24 25 26 27 28 29 30 31  | 
    
      # File 'lib/rex/logging/sinks/stream.rb', line 23 def log(sev, src, level, msg) # :nodoc: if sev == LOG_RAW stream.write(msg) else stream.write("[#{}] [#{log_code_for(sev)}(#{level})] #{src}: #{msg}\n") end stream.flush end  | 
  
#log_code_for(sev) ⇒ Object (protected)
This method returns the corresponding log code for the given severity
      44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59  | 
    
      # File 'lib/rex/logging/sinks/stream.rb', line 44 def log_code_for(sev) code = 'i' case sev when LOG_DEBUG code = 'd' when LOG_ERROR code = 'e' when LOG_INFO code = 'i' when LOG_WARN code = 'w' end code end  |