Class: LogEasy::Appender
- Inherits:
-
Object
- Object
- LogEasy::Appender
- Defined in:
- lib/logeasy/appender.rb
Overview
Appender super class. An instance of this class should not be created. It must be sub-classed. Sub-classes must provide a ‘write’ method that will output a message to the target device. A simple console logger and file logger are provided.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#allow_unformatted_messages ⇒ Object
Returns the value of attribute allow_unformatted_messages.
-
#formatter ⇒ Object
Returns the value of attribute formatter.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#min_level ⇒ Object
Returns the value of attribute min_level.
Instance Method Summary collapse
-
#do_log(log_item) ⇒ Object
Write this log item.
Instance Attribute Details
#allow_unformatted_messages ⇒ Object
Returns the value of attribute allow_unformatted_messages.
19 20 21 |
# File 'lib/logeasy/appender.rb', line 19 def @allow_unformatted_messages end |
#formatter ⇒ Object
Returns the value of attribute formatter.
16 17 18 |
# File 'lib/logeasy/appender.rb', line 16 def formatter @formatter end |
#logger ⇒ Object
Returns the value of attribute logger.
17 18 19 |
# File 'lib/logeasy/appender.rb', line 17 def logger @logger end |
#min_level ⇒ Object
Returns the value of attribute min_level.
18 19 20 |
# File 'lib/logeasy/appender.rb', line 18 def min_level @min_level end |
Instance Method Details
#do_log(log_item) ⇒ Object
Write this log item. If this appender’s level is higher than the log item’s level, this method will return immediately.
‘log_item’ - The log to write.
25 26 27 28 29 30 31 |
# File 'lib/logeasy/appender.rb', line 25 def do_log(log_item) return if log_item.level < min_level # Format the message and log it. # If the log item is marked as unformatted, then simple print, do not format. = log_item.unformatted ? log_item. : formatter.call(log_item) write() end |