Class: Yell::Adapters::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/yell/adapters/base.rb

Overview

This class provides the basic interface for all allowed operations on any adapter implementation.

Other adapters should inherit from it for the methods used by the Logger.

Direct Known Subclasses

Io

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ Base

Returns a new instance of Base.



19
20
21
22
23
24
25
# File 'lib/yell/adapters/base.rb', line 19

def initialize( options = {}, &block )
  @options = options

  self.level = options[:level]

  block.call(self) if block
end

Instance Attribute Details

#levelObject

Accessor to the level



14
15
16
# File 'lib/yell/adapters/base.rb', line 14

def level
  @level
end

#optionsObject (readonly)

Accessor to the options



17
18
19
# File 'lib/yell/adapters/base.rb', line 17

def options
  @options
end

Instance Method Details

#closeObject

Close the adapter (stream, connection, etc).

Adapter classes should provide their own implementation of this method.



39
40
41
# File 'lib/yell/adapters/base.rb', line 39

def close
  raise 'Not implemented'
end

#write(event) ⇒ Object

The main method for calling the adapter.

The method receives the log ‘event` and determines whether to actually write or not.



31
32
33
# File 'lib/yell/adapters/base.rb', line 31

def write( event )
  write!( event ) if write?( event )
end