Class: Scripted::Output::Logger
- Inherits:
-
Object
- Object
- Scripted::Output::Logger
- Defined in:
- lib/scripted/output/logger.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Class Method Summary collapse
Instance Method Summary collapse
- #command_loggers ⇒ Object
-
#initialize(configuration) ⇒ Logger
constructor
A new instance of Logger.
- #send_to_formatters(*args, &block) ⇒ Object
- #start(commands, runner) ⇒ Object
- #to_io(command) ⇒ Object
Constructor Details
#initialize(configuration) ⇒ Logger
Returns a new instance of Logger.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/scripted/output/logger.rb', line 9 def initialize(configuration) @configuration = configuration if block_given? begin yield self ensure close end end end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
7 8 9 |
# File 'lib/scripted/output/logger.rb', line 7 def configuration @configuration end |
Class Method Details
.delegate_to_formatters(name) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/scripted/output/logger.rb', line 24 def self.delegate_to_formatters(name) define_method(name) { |*args, &block| sync send_to_formatters(name, *args, &block) } end |
Instance Method Details
#command_loggers ⇒ Object
20 21 22 |
# File 'lib/scripted/output/logger.rb', line 20 def command_loggers @command_loggers ||= Hash.new { |h,k| h[k] = CommandLogger.new(self, k) } end |
#send_to_formatters(*args, &block) ⇒ Object
48 49 50 |
# File 'lib/scripted/output/logger.rb', line 48 def send_to_formatters(*args, &block) formatters.each { |formatter| formatter.send(*args, &block) } end |
#start(commands, runner) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/scripted/output/logger.rb', line 37 def start(commands, runner) # create all the command loggers commands.each { |c| command_loggers[c] } sync send_to_formatters :start, commands, runner end |
#to_io(command) ⇒ Object
44 45 46 |
# File 'lib/scripted/output/logger.rb', line 44 def to_io(command) command_loggers[command].to_io end |