Class: Scripted::Output::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/scripted/output/logger.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#configurationObject (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_loggersObject



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