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
-
#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.
-
#level(severity = nil) ⇒ Object
Set the log level.
-
#write(event) ⇒ Object
The main method for calling the adapter.
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( = {}, &block ) @options = level [:level] instance_eval( &block ) if block end |
Instance Attribute Details
#options ⇒ Object (readonly)
Accessor to the options
14 15 16 |
# File 'lib/yell/adapters/base.rb', line 14 def @options end |
Instance Method Details
#close ⇒ Object
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.
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 |