Class: Yell::Adapters::Base
- Inherits:
-
Object
- Object
- Yell::Adapters::Base
- 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
Instance Attribute Summary collapse
-
#level ⇒ Object
Accessor to the level.
-
#options ⇒ Object
readonly
Accessor to the options.
Instance Method Summary collapse
-
#close ⇒ Object
Close the adapter (stream, connection, etc).
-
#initialize(options = {}, &block) ⇒ Base
constructor
A new instance of Base.
-
#write(event) ⇒ Object
The main method for calling the adapter.
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( = {}, &block ) @options = self.level = [:level] block.call(self) if block end |
Instance Attribute Details
#level ⇒ Object
Accessor to the level
14 15 16 |
# File 'lib/yell/adapters/base.rb', line 14 def level @level end |
#options ⇒ Object (readonly)
Accessor to the options
17 18 19 |
# File 'lib/yell/adapters/base.rb', line 17 def @options end |
Instance Method Details
#close ⇒ Object
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 |