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.



16
17
18
19
20
21
22
# File 'lib/yell/adapters/base.rb', line 16

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

  level options[:level]

  instance_eval( &block ) if block
end

Instance Attribute Details

#optionsObject (readonly)

Accessor to the options



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

def options
  @options
end

Instance Method Details

#closeObject

Close the adapter (stream, connection, etc).

Adapter classes should provide their own implementation of this method.



36
37
38
# File 'lib/yell/adapters/base.rb', line 36

def close
  raise 'Not implemented'
end

#level(severity = nil) ⇒ Object

Set the log level.

For more examples, refer to Level.

Examples:

Set minimum level to :info

level :info


46
47
48
# File 'lib/yell/adapters/base.rb', line 46

def level( severity = nil )
  @level = Yell::Level.new( severity )
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.



28
29
30
# File 'lib/yell/adapters/base.rb', line 28

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